You definitely need to know how to customize your WordPress website once you learn the WordPress basics. We consider child themes as an excellent starting point for anybody looking to customize WordPress themes. In this tutorial, we’ll show you the best way of creating a child theme in WordPress.
The benefit of creating WordPress Child Theme
Without any doubt, child themes are the best means of personalizing your WordPress themes. A child theme inherits all of the attributes and looks of its parent theme. This way, you can modify the parent theme without affecting it. You have the freedom of updating the parent theme without hampering your changes.
The Requirements of Creating a Child Theme
To create a WordPress child theme, you need a fundamental knowledge of CSS/HTML, so you can make your custom changes. Some familiarity with PHP would definitely help too. Being skilled at copying and pasting code snippets from external sources will also come in handy.
Creating Your First Child Theme
All you need to start with is a good WordPress theme which will be used as a parent theme. Nevertheless, there are lots of themes and many of them might not be that easy to work with. In this tutorial, we will utilize Twenty Thirteen theme – one of the very good default WordPress themes.
Proceed to must open path /wp-content/themes/ in your WordPress setup folder. You can easily do this using an FTP client. We have a tutorial to put you through the nitty-gritty of using an FTP client here.
Create a new folder in the path for the child theme. You can, however, name this folder whatever you would like. For the sake of tutorial, we will name it wpmanualDemo.
Open any text editor such as Notepad or Sublime Text and paste this code in it:
Theme Name: WPB Child Theme
Theme URI: http://www.wpbeginner.com/
Description: A Twenty Thirteen child theme
Author URI: http://www.wordpressmanual.com
Save the file as “style.css” in the created child theme folder.
The code is self-explanatory. The only thing you need to pay close attention to is the “Template:twentythirteen”. This is a pointer to WordPress that the parent theme directory name is twentythirteen. The name is actually case-sensitive and you should be careful when naming it.
The parent theme’s stylesheet is imported by the final line in this code to the child theme.
That is the minimal prerequisite for making a child theme. Now go to your WordPress admin dashboard and click on “Appearance” >> “Theme”. There you will see the WPmanual Child Themes. You have to click on “Activate” button to begin using the child theme on your website.
As you haven’t altered anything in your child theme yet, your website will use all the functionality and looks of its parent theme.
Customizing Your Child Theme
Every WordPress theme has a style.css file within their primary directory. Ideally, this is the principal stylesheet of your theme and where you will add all CSS code. Nevertheless, some themes may simply have their header info stored in them. Such themes generally have CSS files found in a directory that is separate.
Adding New Functionality to Child Theme
Some WordPress tutorials are always of the opinion that you add all your custom code snippets into your theme’s functions.php file. This means that whenever you update or switch theme, you will lose all your changes. This is the reason why it is advisable you use a child theme and add any change to its functions.php file.
Like every beginner, you are liable to make errors when you make your first child theme. When this happens, the best things you can do is not give up too fast. Take a look at our list of common WordPress errors and how to fix them.
The most common error you can encounter is syntax errors which normally occur when you make a mistake in the code.