How to create Child Theme in WP

It is a must to have a Child Theme for our all customized website themes. When we’re doing customization to our theme’s it is a best practice to do in the child theme why because if you are editing the CSS or PHP files directly in the original theme all your changes will be wiped when you update the theme. So the changes in your child theme untouched by the new updates thus save your precious time and effort make peace of mind.

So in this tutorial I am going to explain by step by step how to create child theme in very simple method.

1. The first thing we need to do is create a new folder in our themes directory to hold the child theme. You can do with using cPanel or via FTP. The themes directory is wp-content/themes.

It’s important to name the folder without any space in the name, and it’s common practive to use the name of the parent theme folder with “-child” added on the end.

So for this example, we’ll be calling our folder “twentythirteen-child”.

 child-theme-folder

2. In the child theme folder, create a file called style.css. This is the only file required to make a child theme.

The style sheet must start with the following lines:

1
2
3
4
5
6
7
8
9
10
11
12
/*
Theme Name: Twenty Thirteen Child
Theme URI: http://wordpress.org/themes/twentythirteen
Description: Twenty Thirteen Child Theme
Author: WPMU
Author URI: http://wpmu.com
Template: twentythirteen
Version: 1.0.0
*/
@import url("../twentythirteen/style.css");
/* =Theme customization starts here
-------------------------------------------------------------- */

You can change each of the lines to suit your theme, but you must keep Theme Name and Template lines as well as the @import section. The template is the folder name of the parent theme, in this case twentythirteen.

3. Now we need to activate the child theme. Login to your WordPress site and go to Appearances > Themes. Find your child theme in the list of available themes and click “Activate”.

4. Your child theme should now be the active theme.

child-theme

Modifying Your Theme’s CSS

Our child theme works a treat and looks just like the parent theme because we’ve imported its CSS file.

If you want to modify the theme’s CSS, you can add any changes to the child theme’s CSS file below the @import line. All new CSS information is applied to your site after the original theme’s CSS is loaded, overwriting it.

Say we want to change the text in our theme so it is bubblegum pink. All we need to do is add a line to the child theme’s CSS file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
Theme Name: Twenty Thirteen Child
Theme URI: http://wordpress.org/themes/twentythirteen
Description: Twenty Thirteen Child Theme
Author: WPMU
Author URI: http://wpmu.com
Template: twentythirteen
Version: 1.0.0
*/
@import url("../twentythirteen/style.css");
/* =Theme customization starts here
-------------------------------------------------------------- */

p { color: #FFDFDD;}

This change to the child theme’s CSS overwrites the original CSS for the parent theme.

Now our site looks like this:

twenty-thirteen

Editing the functions.php File

The functions.php file is where a theme’s main functions are usually kept. If you need to add custom functions to your theme, you can do so by creating a new functions.php file within your child theme folder.

Unlike style.css, the functions.php file in a child theme does not override its counterpart from the parent. Instead, it is loaded in addition to – and right before – the parent theme’s functions.php.

You child theme’s functions.php file should start with a php opening tag and end with a php closing tag. You can add your functions in between.

1
2
3
4
5
<?php

// Stick your php code in here

?>

Editing Other Theme Files

Unlike the functions.php file, the functions for your theme’s other PHP files aren’t imported automatically. Other PHP files are edited by replacing the file with a copy. The theme’s original file is then ignored and the new one is used instead.

For example, if you’re planning to make changes to Twenty Thirteen’s 404.php file, you would need to first make a copy of the old file and paste it into the child theme.

Once the file has been copied into the child theme, you can make any changes you like, safe in the knowledge you can revert back to the parent theme any time you want.

WordPress – Why should you use?

So what is WordPress and why is it raved about so much? We listed good reasons why you should be using it for your business or personal  website. AS the description on the main wordpress.org site says, WordPress is simply web software that creates beautiful websites or blogs. It started in 2003 and is now the largest self-hosted blogging tool in the world, and is used on over 60 million sites that are seen by tens of millions of people every day.

WordPress is an Open Source project which means nobody ‘owns’ it. You are FREE to use it for anything, from your dog’s home page to a FTSE 100 web site without paying anyone a license fee.

You may hear about WordPress.com and WordPress.org  for which there are differences:

  • WordPress.com is hosted for free, but comes with limited functionality (you have to pay to upgrade to use this added functionality).
  • WordPress.org can either be hosted by yourself or if you don’t know how to do that, then a web designer will arrange your hosting (most likely all you’d pay is the cost of the domain name which is often $10 a year). This is the better choice as all the functionality of WordPress is available. The code can easily be ‘hacked’ and any adaptations easily made (see point 5 below).

With WordPress you can build a blog, a website, or both together as one.  It lets you create both pages and posts for your site and use the benefits that come with both.

WordPress is a powerful Content Management System (CMS) that can be used for more than just blogging. It can store all your images, files, documents, links and easily retrieve and use them as you see fit.

It is designed and suited to publishing and changing content easily. You don’t have to have working knowledge of html or css to create a great looking site.

Using the functionality of WordPress (such as widgets, plugins, and themes) requires no code experience or expertise, as anything can be added, removed, and rearranged within the WordPress Administration panel.

So rather than having to rely and pay someone to update it for you, you can log on an have full access to do whatever you want – amend spelling mistakes, add and delete pages or posts, change the look and feel of your site. You name it, there will be a way to do it, and all within your control.

There are thousands of widgetsplugins and themes available to transform your site into almost anything you can imagine:

  • free design themes to give your site a completely different look at the click of a button
  • the ability to extend your website with logos, polls, newsletter sign-ups, contact forms, ratings or hundreds of other cool features
  • eCommerce shopping cart plugins can list products, services and digital downloads and take any means of electronic payment.

All tools are available without having to hire a web developer to install or set up and configure them.

There are hundreds of people all over the world working on WordPress to continually update and improve the way it works and what it offers.  The wordpress.org/support site is fantastic and features extensive forums as well as documentation on anything you can think of to do with WordPress.

There are also thousands of other support sites, blogs, forums, Twitter feeds, newsletters, videos, podcasts and more all focusing on top tips and tricks to get the most out of WordPress. Any help you need is literally just a Google search away!

You can of course makes an amazing site, but this is pointless unless it can be found easily through the many different search engines available. Luckily WordPress provides many excellent seo benefits and most are completely free. This includes guiding search engine crawlers through posts, pages, and categories, the ability to create permalinks, plus blogrolling, and pinging. There are also a large number of third party plugins and hacks which can be used for search engine optimization (SEO).

It really is. You shouldn’t be asking yourself  ‘why should I use WordPress’  for my site but really  ‘why shouldn’t I be using WordPress’!

I use it daily to create websites for friends, colleagues and customers, for both personal and business use.

All sites that I have created in WordPress have been perfect for their owners and have really impressed.