BLOG

A LITTLE STORY ABOUT MY JOURNEY

WordPress Child Theme

WordPress Child Theme

According to our recent WordPress Themes Survey, 85% of our customers customize their themes, and only 35% use a child theme when doing so. This may be due to a lack of understanding as to what a child theme is, or due to the perceived difficulty of creating one. In this tutorial, we will go over how to create and use child themes, and why using them is so important. (A special note for Elegant Themes customers only: If you are only looking to perform simple CSS changes to your theme, then you can use the Custom CSS box in ePanel instead of creating a child theme. For more in-depth changes that require editing php files, a child theme must be used.)

Why You Should Be Using Child Themes

Creating a child theme when performing adjustments to your theme’s code can save you a lot of future headache. Child themes allow you to make changes without affecting the original theme’s code, which makes it easy to update your parent theme without erasing your changes. By creating a child theme, you create a separate set of files that you can use to customize the theme without affecting the original theme at all. Not only does this make updating easier, it also makes sure that you will never ruin your original theme as you are never actually modifying the files. You can always turn off your child theme and fall back on the original.

There are a few reasons why you would want to use a child theme:

  • If you modify a theme directly and it is updated, then your modifications may be lost. By using a child theme you will ensure that your modifications are preserved.
  • Using a child theme can speed up development time.
  • Using a child theme is a great way to learn about WordPress theme development.

 

 

Process to create child theme:

Fortunately, creating a child theme is a piece of cake – all you need to do is create one folder, and one file.

You will need access to your website via either FTP or your hosting provider’s file manager application. I would recommend that you get yourself set up with an FTP account (using software such as Filezilla), as it is easier to add and edit files and folders that way.

1.   Creating Your Child Theme’s Folder

Inside the theme directory (wp-theme) create a new directory with parent theme –child (like twentyeleven-child)

2.  Creating Your Child Theme’s style.css File

Once you have created your folder, you need to add the one and only file that is required to create a valid child theme – style.css.

 

You’ll need to place some vital information inside of this file, so open up your favorite text editor and paste the following into a blank file:

 

There is one other thing of vital importance that you must do. If you were to upload this file in its current state and activate your child theme, WordPress would look to your child theme’s style.css file as the default style file, and see nothing. As a result, your theme would render with absolutely no CSS styling. Therefore, you need to call the parent theme’s CSS file within your child theme’s style.css file, with the following line of code:

  1. @import url(“../parenttheme/style.css”);

 

3.  Activating Your Child Theme

Navigate to “Appearance > Themes” in your WordPress admin area. There is list of available theme with your current child-theme. By clicking the activate button you can activate the your child-theme.

4.  Making Further Alterations and Additions

If you want to change other parent file you can easily create filename as parent file then you can write your own custom code. Like : we need to change some function form functions.php file then inside the child theme make functions.php file then write only what you need.

 

Reference :

http://codex.wordpress.org/Child_Themes

 

837 Total Views 1 Views Today