creating childthemes in wordpress

Setting up a WordPress website to look the way you want, can often be achieved by choosing a suitable theme and then configuring the theme's individual options. Areas such as the home page, portfolio page, contact page, blog page, headers and footers can be adjusted in the theme options settings.However sometimes you may need that extra level of customisation that can only be achieved by modifying the website's CSS and PHP code. You may want to create a new page template, or add some custom SEO data into a page's header, or add a script onto certain pages, or add Google fonts, or tweak the design to enhance the website's appearance and function.

This is why you should always create a CHILD THEME for your WordPress powered website.

Child themes in WordPress are easy to create and are the ideal way to customise a WordPress theme. The main reason for making a childtheme, is because if you just modify the parent theme when trying to setup your WordPress website to create look the way you want, then you risk losing ALL your changes when you update the theme.

So how do you create a childtheme in WordPress?

Well basically you start with a style.css file. This is the minimum required to run a childtheme for your WordPress blog. You will need to create a theme folder to insert the stylesheet into. So if your main WordPress theme was called Moderntheme, then you could call this new folder moderntheme-child.Create a file called style.css and insert the following code at the top of the file:/*

Theme Name: My Childtheme Name

Theme URI: http://link-to-your-website

Description: Purpose and what is this childtheme

Author: Your Name

Author URI: http://link-to-your-website

Template: exact-folder-name-of-the-parent-theme (this is case sensitive)

*/



@import url("../exact-folder-name-of-the-parent-theme/style.css");



/* insert your custom css code between here */







/*and here*/



Now you have created the file that will enable you to make your first childtheme. Upload this file via FTP inside a folder called "my-childtheme-name", to wp-content > themes, and then activate your childtheme inside the Wordpress admin dashboard.If you are using a responsive theme, one that adjusts automatically for mobile browsers, then you will need to copy across all of the responsive code, from your parent theme's stylesheet, and add it into your childtheme's stylesheet, to ensure that it continues to work correctly.

Creating a functions file

This is also very easy, all you need to do is to create a php file called functions.php inside your childtheme folder and add the following: <?php

/*start functions code*/



/*end functions code*/

Modifying page templates

Sometimes you may want to make modifications to page templates, header files, footer files, etc. The best way is to make a copy of the file from the parent theme, and then add this to your childtheme and make your modifications there. This will then replace the parent theme templates.

Making sure it works

Sometimes things don't work the way they should. Some themes don't link to the style.css file, so if your CSS changes are not working, check to make sure that there is a link to your stylesheet in the header. If necessary, add the following code to the header.php file, following all the other stylesheet links. <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_uri() ?>" />

Always backup your website first

Anytime you are making some changes on your website, you should ensure you have a current backup. Although setting up a childtheme can be quite easy, if you are considering doing this on an existing WordPress website, backup everything first. It pays to play it safe. So that's a quick guide on how to setup a childtheme for your WordPress website. [dtwd-related-posts-sc title="For more ideas and tips:" count=3]

Comments: