Using a child theme with Hueman

Why should you use a child theme?

Creating a child theme is the best way to start customizing the  Hueman WordPress theme (and any WordPress themes).

There is one major reason for that : you won’t loose any of your customizations when you’ll update the parent theme! If you edit directly the style.css or functions.php files of your theme, the next update will just delete everything. 

Note : Keeping your parent theme up to date is highly recommended as it will guarantee an optimal security, fix bugs or ensure browsers compatibility.

Besides, using child themes is a good development practice : in your child theme you focus only on your added style functionnalities, there are less files to edit and to maintain. If you come back to your code after a while, it is much easier to understand than having to dive into the parent theme and look for all your customizations in each php template and file…

How to create a child theme for the Hueman theme?

1) Simplest way : create your child theme in a few clicks with Childify Me

You can use a plugin to create a child theme in a few clicks. This works great and requires no coding or file transfer.

  1. Download and activate the awesome and free Childify Me plugin
  2. Go to Appearance > Customize. There, you’ll see a new link added by the plugin in the text description’s footer. See screenshot below.
  3. Click on the button Childify Me
  4. Name your child theme
  5. Go back to Appearance > themes, find your freshly created Hueman child theme and activate it. You are done!

This plugin is really cool since it will even generate a screenshot image (based on the parent theme) for your child theme to help you identify it in your list of themes. I strongly recommend this method for newbie and event for developers as it is really simple, safe and fast.

Note : The Childify Me plugin creates a style.css  and a function.php files. If you want to add custom functions or templates in new folder/files, you can either upload them by FTP or use the following plugin to easily manage your files right from admin :  http://wordpress.org/plugins/wp-filemanager/

2) With a ftp access (for developers)

Well, it is pretty simple. You need to create a folder and a file.

  1. Connect to your server via you FTP client and create a folder in the themes directory. You can name it as you want but without any spaces or special characters in the child folder name.
  2. Create a style.css file in this folder and copy and paste the following code in it. The important point here is to write the parent template parameter name ( Template : hueman ) in small letters, no cap letter, as it is case sensitive.
/* 
Theme Name: My Hueman Child Theme  
Theme URI: http://mysite.com/ 
Description: My description 
Author:Me
Author URI:http://mysite.com/
Template: hueman
Version: 1.0.0
*/

How to override Hueman templates and core functionalities with a child theme

Adding style to your child theme from your WP admin

While this is not recommended for adding php customizations, you can use the WP editor in Apperance > Editor to add custom css rules to your child theme.

Make sure you select the child theme in the dropdown list at the top, edit and save.

Child theme overwrite logic

When a child theme is created and activated, WordPress compares all paths to the files of the child and the parent theme. Each time a match is found, the child theme path/file will be used first and will override the parent theme file.

There is one exception though : the functions.php file of the child theme is loaded in addition to and before the parent’s functions.php.

For example, if you create a index.php template in your child theme, it will overwrite the parent index.php template file.

Pluggable functions

The fact that the functions.php file of the child version is read just before the parent version can be very useful if you want to replace functions in the original functions file.

To enable this particular behaviour, the theme developers have to write their functions in specific way  : this is what we call make the function pluggable :

A pluggable theme should have all its functions (in the functions.php file) wrapped like this :

if( ! function_exists('name_of_function') ) { function name_of_function( $params ) { // do some stuff with the $params } }<br>

This gives child theme developers the ability to completely replace functions declared in the parent theme. By the time WP finds them in parent functions.php, they exist and get skipped (because of the function_exists() condition).

Additional resources about child themes in WordPress