Extra Step to Make Sure Your WordPress Theme is Child Theme Ready

Many Web Developer had been using Child Theme from an existing WordPress Framework to save time and avoid extra ‘grunt’ work from developing a new WordPress Theme for their clients or personal use. There are tons of Free WordPress Framework available on the internet. Here are some of the popular and free to use one:

If you’re a serious and dedicated web developer, then there’s a premium or paid version of WordPress Framework such as Genesis and Thesis.

What is WordPress child theme?

WordPress child theme is a theme that inherits the functionality of another theme, called the parent theme, and allows you to modify, or add to, the functionality of that parent theme.

Here i will point out couple of extra step you can take to make sure your WordPress Theme is ready to use in child theme development.

1. Add child style.css for your theme

Make sure you include a child-folder inside your WordPress Theme so its easy for other users to create a child theme from your WordPress Theme. its easy, just create a new folder in your theme named child-YOUR-THEME-NAME and add a new style.css inside along with empty screenshots. Content inside child theme style.css should be similiar like this:

/*
Theme Name: Theme Name Child
Theme URI: http://www.link-to-parent-theme.com
Version: 1.0
Description: Child Theme for Parent Theme Name
Author: Your Name
Author URI: http://www.yoursite.com
License: GNU General Public License
License URI: http://www.opensource.org/licenses/gpl-license.php
Template: Parent-Theme-Name
*/
@import url("../Parent-Theme-Name/style.css");

2. Proper Action Hooks in Template

This is important for users to add an action hook to your Parent WordPress Theme. Basically its to make the process of editing template layout more convenient and avoid users edits the parent template. You should add do_action() hook to your templates:

<?php do_action('wp_before_content'); ?>
<div class='content'> some code here </div>
<?php do_action('wp_after_content'); ?>

well, you get the point.

3. template_directory() vs stylesheet_directory()

To make sure any template in parent theme are editable via child theme, you should add condition to your include() file like this:

<?php
if( is_child_theme() && 'YOUR-PARENT-THEME-NAME' == get_template() && file_exists( get_stylesheet_directory() . '/custom-functions.php' ) ):
include( get_stylesheet_directory() . '/custom-functions.php' );
else:
include( get_template_directory() . '/custom-functions.php' );
endif;
?>

Conclusion

Its not necessary to take this extra step to prepared your WordPress Theme for child theme. Framework like Genesis or Thesis use a good example of apply_filter() for their theme templating which is much easier if you know how to use add_filter() WordPress core function. Hopefully, this guide will help you understand more about preparing your theme for child theme usage.

Extra Step to Make Sure Your WordPress Theme is Child Theme Readyhttp://cdn.dezzain.com/1/2013/08/wordpress-child-themes.jpghttp://cdn.dezzain.com/1/2013/08/wordpress-child-themes-300x300.jpg Richie KS WordPress TutorialsChild Theme,wordpress coding,WordPress Tips
Take this extra step to make sure your WordPress theme is child theme ready. Create a child theme style-sheet inside your parent theme and adding conditional template path for template edits.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>