Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
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.
In a previous movie, I showed you the custom front page template and how it has separate wigitized areas, or sidebars, than the regular page templates. In the widgets area you can actually see it in the back end. You have the Main Sidebar, which is what appears on posts and regular pages, and then you have this First Front Page Widget Area and Second Front Page Widget Area, that only appear under the custom page template when that template is being used. Thanks to the WordPress template hierarchy, we can make custom templates to suit pretty much any need. This includes making custom header, sidebar, and footer templates that appear only when we want them to.
In the Twenty Twelve theme, we already see one such custom template, which is one that kicks in this, First Front Page Widget Area and Second Front Page Widget Area. Let's take a look at that template. If you look at the twentytwelve theme and we will scroll down to the bottom here, you see we have two templates; we have sidebar and sidebar-fronts. If you look at sidebar, you see all it does is call the sidebar-1, which is the main sidebar.
If you look at sidebar-fronts you'll see the same thing happens except here we are calling sidebar-2 and sidebar-3. These correspond with these First Front Page Widget Area and Second Front Page Widget Areas. But where do they come from? Well if you look at the page template, when we scroll all the way to the bottom, you see here it says get_sidebar; this is a general call, if I called the sidebar.php page. It's the same type of call you used to call the footer.phpfile, get_footer, and also the header.php file, get_header.
But if you go back to twentytwelve and go into page templates, the folder, and open the front page custom page template, you see that instead of just calling get_sidebar, we're adding a variable, front. This tells WordPress that instead of calling sidebar.php it should be calling sidebar-front.php. So that's how the custom sidebar kicks in, in a custom page template. Now you have a clear idea of the naming structure and how this works, and it's actually really simple.
If you want to create a custom header, footer, or sidebar at any point in your site, all you do is as you create a custom file called header- and then give it the name that you want to use, and then to call it, you simply go get_header then define that same name. The same goes for sidebar and footer as well. This is what actually happens. If we use the regular page.php template, we have the function call get_header that calls the header.php template.
However, if we decided to create custom header file that we only wanted to appear in our no-title-page template, we would add get_header parentheses custom in our function, and that would call the header-custom.php file instead. The same exact technique applies to sidebar.php and footer.php as well. By utilizing the built-in functionality of the template hierarchy, you can create custom layouts and content displays on pretty much any page on your site.
This allows you to add and subtract content in areas like the header, sidebar, footer, depending on what page, post, or index the visitor lands on, and that can in turn be used to give the visitor a more meaningful and informational experience when visiting your site.
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.