New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Start learning with our library of video tutorials taught by experts. Get started

WordPress 3: Building Child Themes
Illustration by
Watching:

Adding a new footer menu to Twenty Twelve


From:

WordPress 3: Building Child Themes

with Morten Rand-Hendriksen

Video: Adding a new footer menu to Twenty Twelve

Pretty much all WordPress themes come with a main menu in the header, and most of these themes have the main menu wired to the WordPress menu system for easy configuration. I'd like to add an extra menu in the footer as well so that if a person has reached to bottom of the site, they can navigate to all my important pages without having to scroll back to the top of the page. Using a child theme, adding the menu like this, is very easy. To add a new menu we have to do three things. We have to add the menu to the existing menu function using function.php, we than have to add the menu to the template files, and then we have to style the menu to make it look nice.
Expand all | Collapse all
  1. 6m 59s
    1. Welcome
      1m 6s
    2. Using the exercise files
      1m 34s
    3. What you need to know before watching this course
      1m 29s
    4. Getting the right tools for theme creation
      2m 50s
  2. 17m 2s
    1. What is a WordPress child theme and when should you use it?
      2m 38s
    2. Picking a parent theme
      3m 55s
    3. Making sure you have the Twenty Twelve parent theme
      1m 50s
    4. Creating and activating a basic child theme
      4m 20s
    5. Importing parent theme styles
      4m 19s
  3. 16m 2s
    1. Using the developer tools
      3m 53s
    2. Modifying existing styles
      4m 24s
    3. Adding space between paragraphs
      4m 7s
    4. Changing font family styles
      3m 38s
  4. 31m 47s
    1. Understanding the WordPress template hierarchy
      3m 12s
    2. Modifying existing templates
      2m 33s
    3. Moving the header image
      4m 29s
    4. Adding Related Posts feature to posts
      6m 26s
    5. Creating custom page templates
      5m 43s
    6. Using conditional statements for customized effects
      5m 41s
    7. Creating custom header, footer, and sidebar templates
      3m 43s
  5. 17m 5s
    1. Understanding the different index pages and what they do
      4m 6s
    2. Adding author, date, and time information to the index loop
      7m 15s
    3. Changing the appearance of category index pages
      5m 44s
  6. 43m 5s
    1. Introducing functions.php
      3m 24s
    2. Overriding existing functions
      3m 23s
    3. Adding pagination to index pages
      5m 49s
    4. Adding to existing functions
      3m 21s
    5. Adding a new footer menu to Twenty Twelve
      6m 24s
    6. Adding a new widgetized area to pages
      4m 9s
    7. Adding static content to the sidebar
      7m 44s
    8. Replacing existing functions
      2m 36s
    9. Adding a Google font through a function
      6m 15s
  7. 10m 24s
    1. Adding new featured image sizes
      5m 41s
    2. Adding featured images to posts and pages
      4m 43s
  8. 31m 1s
    1. Adding a welcome message to the front page
      1m 22s
    2. Displaying page content in an index page
      7m 42s
    3. Hooking in a featured image
      4m 34s
    4. Making the welcome message responsive
      6m 27s
    5. Restricting content to the first page of the blog
      4m 22s
    6. Adding a jQuery function to show or hide the welcome message
      6m 34s
  9. 10m 23s
    1. Adding a custom favicon
      3m 58s
    2. Adding a custom screenshot
      2m 29s
    3. Adding footer information
      3m 56s
  10. 7m 14s
    1. What to do when a child theme crashes your website
      4m 38s
    2. Updating parent and child themes
      2m 36s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
WordPress 3: Building Child Themes
3h 11m Intermediate Jun 23, 2011 Updated Nov 27, 2012

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.

Topics include:
  • Picking a parent theme
  • Creating and activating a basic WordPress child theme
  • Using the developer tools
  • Changing the header image size
  • Using conditional statements for customized effects
  • Adding custom menus to the child theme and/or a template
  • Changing the default footer content
  • Adding featured images to posts
  • Changing the display of meta content (such as date, author, category, etc.)
  • Excluding categories from the front page with custom queries
  • Including functions from external files
  • Identifying and fixing common mistakes
Subjects:
Web CMS
Software:
WordPress
Author:
Morten Rand-Hendriksen

Adding a new footer menu to Twenty Twelve

Pretty much all WordPress themes come with a main menu in the header, and most of these themes have the main menu wired to the WordPress menu system for easy configuration. I'd like to add an extra menu in the footer as well so that if a person has reached to bottom of the site, they can navigate to all my important pages without having to scroll back to the top of the page. Using a child theme, adding the menu like this, is very easy. To add a new menu we have to do three things. We have to add the menu to the existing menu function using function.php, we than have to add the menu to the template files, and then we have to style the menu to make it look nice.

To start off with, we need to create a new function that we can register a new nav menu in. So I am going to copy the original function that creates the original menu from the function.php file in the parent theme and then I am going to open the functions.php file in my child theme and create a new function in which I'll register the new menu. So I'll start by creating a new function. I'll call it mychildtheme_setup. And within this function I'm going to place the register_nav menu function.

Now I have to change some variables here. I'll change primary to secondary and I'll change Primary menu to Footer menu, because that's what I want. Now, this won't run on it's own. I also need to add an action that'll trigger my child theme setup so that it'll run when you open the theme. So I'll go back to the function.php file and take a look at how that's done. It's right down here, add_action( 'after_ setup_theme,' and then it's calls the function. So I'll copy that, paste it in, and then I just have to change the function that's being called to match the new function I created.

I'll save that and when I go to Menus in the backend of my site, you'll see we now have two menus: we have the Footer menu and Primary menu. This doesn't look right though, because the footer menu is listed before the header menu. That's actually because, as I explained before, the functions.php file from your child theme is called before the functions.php file from your parent theme. But we can fix it quite easily. You can delay the action that's happing here by simply going comma and putting in a number like 11.

That just means that this action will be called after everything else has been called. So when I saved this and reload my Admin page, Primary menu is on top and Footer menu is on the bottom. Now you see I have already assigned this Footer menu to the footer menu area, but if I have visit my site and scroll down to the bottom, there is no menu. That's because I still need to add the menu to my theme. Now, there are two main methods for calling a menu into a template file.

You can either call it based on the theme location--that is, the name that we put in, either primary or secondary or something else--or you can put it in based of the name the menu is given inside WordPress admin. They're used for different purposes. If you want to make a menu area where people can assign any menu they want to it, you would do it like this. You would call the theme location, because then people can assign whatever menu they want. If you want to make it easy for people to use your theme and say if you decide to make menu that's called Footer menu, it automatically appears in the location, then you would use this function instead, name.

I'm going to use the first one here, theme-location. I know where I want to put the menu. It's going to be in the footer. So logically, I have to go to my parent theme, find the footer template, and copy it over to my child theme. Now I can edit my child theme footer template and place my menu here. So I'll say nav id="footer_menu"> and then inside here I'll put that function.

And the location I gave it is in the function file, secondary. So I'll copy out that secondary and then I'll end my array, end the function, end my PHP delimiter, save it, and if everything went right, we now have a menu here at the bottom. It doesn't look very nice, but it is definitely a menu. Now we need to add styling to the menu to make it match the rest of the site. However, I already have a menu on my site that I think looks pretty nice and I don't really want the footer menu to look any different.

So instead of creating all new styles for the menu, I'm just going to cheat. I'm going to go to the header file right here and then I'm going to find the call to the menu right here. I'm simply going to copy it out and paste it in here in my footer file in place of that functionality I created. And then I'm going change the ID to footer-navigation, change to comment here at the bottom to footer-navigation, and then I'll take out these two lines of code here.

This is the title for the menu and the hidden content for people who use text-to-speech browsers. And though that's really important for you main menu, it's not really all that important for your footer menu. So I am taking it out. The reason why I'm copying this code is because I know the code carries with it all the necessary classes to make the menu use the same styles as the header menu. So all I need to do here is change the theme_location to secondary, save it, and reload my page.

When I scroll down to the bottom, we now have a nice-looking menu at the footer that's different from the top. So now you can go back to Menus and you can create two different menus--one for the header and one for the footer-- and assign them to each of them. By adding a menu to the existing menu functions, we preserved the original menu rather than overwrite it. This way you can add as many menus as you want and create custom navigation for your visitors to find what they're looking for.

Find answers to the most frequently asked questions about WordPress 3: Building Child Themes.


Expand all | Collapse all
please wait ...
Q: The 2010 version of this course no longer covers installing BitNami. Can you provide directions?
A: Instructions on how to install WordPress using BitNami can be found at
 http://bitnami.org/stack/wordpress. Use the "Installer" option. 
It is pretty straight forward and almost impossible to mess up.

lynda.com also has a dedicated course on WAMP and MAMP (Installing Apache, MySQL, and PHP) that is relevant and you might find helpful.
Q:When looking to download PHP development tool at www.eclipse.org/pdt/, as advised by Morten, but when accessing the site via this link, the screenshot in the movie is very different from what it takes you to on the website.
A: Eclipse has a very active developer cycle and updates quite frequently. The interface changes all the time. I recommend using Notepad++ (Windows) or TextWrangler (Mac) instead. They perform the same function but are far less cumbersome to deal with.
Q: This course was updated on 11/27/2012. What changed?
A: This course was heavily revised to reflect changes to the default WordPress parent theme, Twenty Twelve, and updates to WordPress's functionality. The entire course was re-recorded to reflect changes to the interface. Then we added new movies on text styling, the Related Posts feature, and the welcome message features. There are also two brand new chapters, "Modifying and Adding Functions" and "Working with Featured Images." We recommend that members who have seen the whole course start again from the beginning to get the most benefit from this update.
 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed WordPress 3: Building Child Themes.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.