Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
Create a child theme based on an existing parent theme in WordPress and change the functionality, presentation, or styling of your website. In this course, author Morten Rand-Hendriksen shows how to use the default WordPress theme, Twenty Twelve, as a basis for a new child theme and add custom menus; new headers, sidebars, and footers; and index pages with widgets and pagination to your site. The course also demonstrates how to add a responsive welcome message to your front page using PHP and jQuery, and how to edit the many templates found in a WordPress theme. Morten explains how to perform these changes using any code editor, the developer tools in the Chrome browser, and WordPress.
Just like with the stylesheet, you can add modified template files to your child theme to change or add to the original template in the parent theme. But unlike the stylesheet, you don't just add a file with your changes. When you modify or add to an existing template file in a child theme, you replace the original template file. Let me give you an example what I'm talking about. Let's say we want to make it change to the single post view. First, I'm going to go to single post here so we can see the template as it exists now. And then I want to make it change to this template file. I already know that it's the single.php file I need to change.
But before I can change it, I need to make sure have that file in my child theme. What I'm going to do is go to my themes directory and open the parent theme, so here twentytwelve, and then next to it I'll open my child theme, here is childoftwentytwelve. Now I'm going to find the original file, so right down here, single.php and I'll copy it into my child theme. Now when I access a single post on my site, I'm looking at that post using the single.php template found in my child theme.
How do I know that? Well, I can check it very easily. If I open single.php from my child theme in my text editor, I can make a small change to it to make sure that this is in fact a file that's kicking in. So I'll go in here somewhere and I'll say php echo which means it'll type something out 'This is a single.php template from the child theme.' I'll close out my php delimiter and save this.
If I'm using this template which is single.php template found inside childoftwentytwelve, you'll see this piece of text appear when we open a single post. So I'll reload my single post and now you see that text appeared here. This is the single.php template from the child theme, which means we are now using the template from the child theme. That means that just like with my stylesheet, if I make at change and then I don't like that change or make a mistake when I'm editing a template file in my child theme, all I have to do is simply go in and delete the file from my child theme, reload the page, and I now have a template from the parent theme again.
So here you see again this idea of nondestructive editing. You make a change to a file, but you are actually making a change to the copy of the file. So if you make a change and it doesn't work, you can always fall back on the original.
Find answers to the most frequently asked questions about WordPress 3: Building Child Themes.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.