New Post has been published on Better Host Review
New Post has been published on http://www.betterhostreview.com/create-wordpress-child-theme.html
How to Create WordPress Child Theme?
A WordPress Child theme could be very useful when a new update or upgrade of your existing theme is released and you want to update to the latest WordPress theme. Normally WordPress theme developers might release a new version for security or new functionality. It is recommended to keep your WordPress and its theme up-to-date. But without a child theme, if you go to upgrade your WordPress theme, your changes to the current WordPress theme and version will be lost. If you have created a child theme for your WordPress, you are free to update the parent theme and still keep your theme customizations intact. This WordPress child theme basics shows you the very basic steps to create WordPress child theme from your current theme. In the demo, we will be using Pinboard theme.
How to Create WordPress Child Theme?
All WordPress themes will be installed to ‘wp-content/themes’ folder. The first steps is to create a folder for the WordPress child theme. It could be any name you like, just make sure not to include any space or special characters in the name. But the common practise is to add ‘-child’ to your parent theme name. If your parent theme is ‘demo’, then the new child name can be ‘demo-child’, ‘demo-test’. In this way, you can easily identify its parent theme.
Open the WordPress child theme folder, create a stylesheet CSS file there in the name of ‘style.css’. This is the only file required to make a basic child theme. Then write in the CSS file with code like this:
/* Theme Name: Pinboard Child Theme URI: betterhostreview.com Description: Pinboard Child Author: betterhostreview.com Author URI: betterhostreview.com Template: pinboard Version: 1 */ @import url("../pinboard/style.css"); /* =Theme customization starts here------- */
You can custom any of the above code to suit your needs. The only required lines are the Theme Name, the Template. Theme Name is the name of your child theme name. The Template is the directory name of the parent theme. In this case, the parent theme is the pinboard theme, so the Template is set to pinboard. Note that it is case sensitive. If the folder name of the parent is ‘pinboard’, you can’t input ‘Pinboard’ in the Template field.
The ‘Template:’ and @import sections are the most important. The first one refer to the template in its parent theme, the @import is to import the parent’s stylesheet to the child theme stylesheet.
Activate WordPress Child Theme
To activate WordPress child themes, login your dashboard, go to Appearance >> Themes. See below screenshot.
From above screen, you can click Live Preview to preview the child theme in WordPress site, then click Activate to enable the child theme for your WordPress. From now on, if we want to customize a WordPress theme, we can go to the theme settings or options pane for the theme, if we like to edit theme files, the changes will be saved to the child theme file only. For example, you can go to Dashboard >> Appearance >> Editors. See below image:
The @import is to apply styles in the parent theme stylesheet file. The child theme’s stylesheet can be inserted after the /* =Theme customization starts here——- */ section. Since child theme’s styles is included after the parent theme’s, the child theme will therefore override those in the parent theme’s stylesheet.
Except stylesheets for child themes, you can also create template files. Liky the style.css file, you can simply make a file of the same name in the child theme directory, and it will override the equivalent file in the parent theme directory when your site loads. Unlike style.css, other PHP files and template files for your child theme will not import their equivalent automatically, they will however replacing the those files in the parent theme. That’s to say, when a new template file for the WordPress child theme is used, original file from the parent theme will be ignored.