What Is Parent Theme In WordPress?

In WordPress, a parent theme is a type of theme that defines parent by a child theme. It allows WordPress designers to make any changes in a robust WordPress themes and take benefits of them.

However, a parent theme always passes all its features, style, and functionality to the child theme. But the child theme makes changes in the functionality of a parent theme without modifying it.

parent theme

All the WordPress theme managers are based on parent/child property, which allows users to easily upgrade their themes to get new style and functionality. All parent theme are not theme framework but all WordPress theme can be a parent theme.

Further, a parent theme to be a framework, it needs to provide the ability to WordPress developers to customize and modify the theme core functionality without modifying any core theme files. Basically, this task is done by using filters and hooks.

We suggest you, create the child theme to get the custom styling. But, if you wish to add a lot of additional functionality beyond basic CSS changes, then you need to use a perfect theme framework to create a child theme.

Prepare Parent Theme in WordPress

  • The terms stylesheet and template have been used numerous times in many contexts.
  • Typically, stylesheet refers to a CSS file in a theme, and template refers to a template file in the theme.
  • However, these words also have specific meanings when working with parent and child themes.
  • You must understand the difference between a stylesheet and a template when working with parent and child themes.
  • In WordPress, the active theme is the stylesheet, and the active theme’s parent is the template. If the theme doesn’t have a parent, the active theme is both the stylesheet and the template.

Imagine two themes: parent and child.

The following code is in the parent theme’s header.php file and loads an additional stylesheet provided by the theme:

<link type=”text/css” rel=”stylesheet” media=”all” href=”<?php bloginfo(‘stylesheet_directory’) ?>/reset.css” />
  • The bloginfo() function prints information about the site configuration or settings. This example uses the function to print the URL location of the stylesheet directory. The site is hosted at http://example.com, and the parent is the active theme. The preceding code produces the following output:
<link type=”text/css” rel=”stylesheet” media=”all” href=”http://example.com/wp-content/themes/Parent/reset.css” />
  • If the child theme is activated, the output is
<link type=”text/css” rel=”stylesheet” media=”all” href=”http://example.com/wp-content/themes/Child/reset.css” />
  • The location now refers to the reset.css file in the child theme. This can work if every child theme copies the reset.css file of the parent theme, but requiring child themes to add files to function isn’t good design. The solution is simple: Rather than using the stylesheet_directory() in the bloginfo() call earlier, use template_directory(). The code looks like this:
<link type=”text/css” rel=”stylesheet” media=”all” href=”<?php bloginfo(‘template_directory’) ?>/reset.css” />
  • Now, all child themes properly load the parent reset.css file.
  • When developing, use template_directory in stand-alone parent themes and use stylesheet_directory in child themes.


Leave a Reply

Call Now