Posted on 1 Comment

Today I have learned One Thing: A Grand Child Theme as a Plugin, and more…

Yes, I said “and more” because I have read other posts regarding grand-child theme as a plugin, primarily by Mark Barnes in his blog with snippets that I am using right now and from my Professor, WPProf. Justin Tadlock. I start by quoting what Tadlock has ssaid in his blog

The idea of parent/child themes became popular because it allowed the parent theme to be updated while keeping customizations intact within a child theme. That system works great. The problems begin when a child theme is updated. Users tend to want to take advantage of the update, but they can’t upgrade because they’ve made customizations

Essentially, we’ve just added another layer to the preexisting problem.. []

Justin clearly differentiates

  • theme framework
  • parent theme,
  • child theme, and
  • grand-child theme

As I always say, Mr. Radlock is very rational, and his logic is simple and easy for me to understand. Well I am not a native English speaker, and I am not a WordPress graduate either. So I can see how difficult it is for me to understand what others are saying when I read their articles on WordPress. This sounds subjective, but I am just saying the truth for myself.

Below is the diagram for reference that Mr. Tadlock has presented in his blog

Theme structure when using a framework, parent theme, and child theme
Theme structure when using a framework, parent theme, and child theme

Theme framework is inside parent theme, and child theme is at the same level as the parent theme.

Next I am going to quote what Mark Barnes said on his blog about this very topic:

Child themes are the easiest way to style WordPress sites. Rather than create a site from scratch, you can create a theme that shares most of its code and styling with a parent theme. The benefits of creating a child theme instead of editing the main theme is that if the main theme gets updates, none of your changes are lost.

But what if you need to modify a child theme? If you’re working with a Framework, like Genesis, it’s very likely you are already using a child theme – and editing that brings about all the disadvantages of editing a parent theme – you lose your changes if the theme is ever updated.

The solution is surprisingly simple. Instead of editing the child theme, create a grandchild theme. It’s very similar to creating a child theme, except you do it via a plugin. You add your custom functions to the plugin, just as you normally would in functions.php (though remember your plugin will be called much earlier than functions.php, so you’ll need to make sure that any code in your plugin only runs when an action is fired).


So far so good, so far I understand what Tadlock and Barnes are saying here. The next challenge for me is this very question,

  • Can I call more than One Grand Child Theme in this one plugin?

Thankfully, the answer is “Yes, absolutely, I can call as many grand child as possible.

This is what I have added

  1. I added a “if ( current_theme_supports( ‘grand-child-theme’ ) ): statement
  2. Then call “what is the name of support, in this case, I have named two different names for two separate style.css; the first one is “hyk-style.css” and “hykchild.css”
  3. These two styles were previously my child themes, but I am now making them become grand-child themes. In fact I can create as many grand child themes as I want.
  4. Then go to the Child Theme “functions.php” and add_theme_support there. These are the two add_theme_supports that I have added for the two Grand Child Style I mentioned above: “add_theme_support( ‘hyk-style’ );
    add_theme_support( ‘hyc-gc-style’ );”
  5. Here is two example of such “if_current_theme_support”
if ( current_theme_supports( 'grand-child-theme' ) ){ if ( current_theme_supports( 'grand-child-theme' ) ){     wp_register_style ('grandchild_style', plugins_url('hyk-style.css', __FILE__).'', array(), $timestamp); }

if ( current_theme_supports( 'hyc-gc-style' ) ){     wp_register_style ('grandchild_style', plugins_url('hykchild.css', __FILE__).'', array(), $timestamp);}

What I do after all these is to comment and uncomment on both

  • add_theme_support( ‘hyk-style’ ); and
  • add_theme_support( ‘hyc-gc-style’ );

If I un-comment “add_theme_support( ‘hyk-style’ ); ” then the grand-child theme delivers “add_theme_support( ‘hyc-gc-style’ );” into my Child Theme.

I must remind myself that I cannot add_support to both of them, because the grand-child theme will call both styles which is not what I want to do.

I hope this is clear for now.

Before I end, I found out that there is another article on grandchild theme by  ·that was written in 2014, “A Theme Framework, Child Themes, & Grandchild Themes“. His explanation makes sense for me of what Justin Tadlock has said in his article, and this is a good article to read.

1 thought on “Today I have learned One Thing: A Grand Child Theme as a Plugin, and more…

  1. […] I wrote about Creating Grand Child Theme, well, I called it Hybrid Grand Child Theme. A day before that I talked about how I call YUI CSS […]

Leave a Reply

Your email address will not be published. Required fields are marked *