Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Creating a custom footer sidebar template

From: Create an Online Portfolio with WordPress

Video: Creating a custom footer sidebar template

So far in this course I have showed you how to create custom post types and also custom taxonomies that are attached to these custom post types, and I have showed you how to create custom templates for each of the custom post types, index pages for all the custom post types, and also index pages for the custom taxonomies. But there's no point having custom post types on your site if no one knows they're there. So now we need to create some features on our site to tell people that the custom post types are available and make them go look at them.

Creating a custom footer sidebar template

So far in this course I have showed you how to create custom post types and also custom taxonomies that are attached to these custom post types, and I have showed you how to create custom templates for each of the custom post types, index pages for all the custom post types, and also index pages for the custom taxonomies. But there's no point having custom post types on your site if no one knows they're there. So now we need to create some features on our site to tell people that the custom post types are available and make them go look at them.

A simple way of doing this is to display links of the five latest posts in each post type in the footer on the site. That way no matter where the visitor is on the site shall see that there's more content just waiting to be read or seen. If we look at the site right now, you will see that on the front page we don't have any links to the custom post types yet, and more importantly, there is no actual way of getting there. So what we are going to do is place links in the footer here so that people can see it. And this is important, what I am going to show you in this movie does not apply just to a sidebar or just the footer.

The techniques I am going to show you on how to grab this content and display it as links can apply anywhere. You can put the same kind of code in the page template, in an index page, or anywhere on the site. We are just using the footer because it's an easy place to work in. To start off, we are going to make some changes to the sidebar-footer file that we find inside twentyeleven theme. Because we are working with a child theme, I am going to grab that file. It's right here, sidebar-footer, and I will copy it and paste it into my child-theme.

By the way if you want to know more about how to customize sidebars in child-themes, you should go check out the chapter on sidebars that's in the WordPress 3: Building Child Themes course right here on lynda.com. Now that I have the sidebar-footer file in my child theme it will override the sidebar-footer file in twentyeleven, which means any changes I make in this file. will be the ones you see on the site. So I will open the file and here I need to make some changes. The first thing I am going to do is remove this batch of code at the very top.

This only applies if you've configured your site the way I did using twentyeleven. In twentyeleven I've set the site to display without any sidebars on the side, and as a result twentyeleven by default will display the sidebar widgets underneath one another. But that's not what I want so I am going to take this code away, because that's the code that decides how this is going to happen. And instead I am going to go into this div at the very top and where it says twentyeleven_footer_sidebar_class, I am going to replace that by saying simply class= and then "three," because I am going to add three widgetized areas to the footer.

Now I am sure you are going to ask, "But I can't see any widgetized areas in the front page," and if we go to it, you'll see you don't see any widgetized areas here. There is a good reason for that. The way twentyeleven is setup, if you don't actively add sidebar widgets to the sidebar, nothing appears. What we want to do is change that so that if you don't actively add widgets to the footer-sidebar, instead WordPress will display default content and that default content is the lists of the five most recent items from each of the custom post types.

If you look at this code, you will see it's pretty easy to understand. It says if there is an active sidebar called 'sidebar-3', then display the sidebar information, and then it says the same thing below. is_active_sidebar 4 and is_active_sidebar 5. What we are going to do is change this code around so that it displays the sidebar items even if there are no active widgets in them. This is a bit of a clunky piece of code, so I provided it in the code snippets. If you go to the snippets file, you will find it at the very top here. It starts with div id="first" and ends with first.widget.area.

So I can copy this out and go and paste it in, in place of the first widgetized area at the top here. Right now it only contains dummy content, but I will show you how it all works. First, it adds a simple div with the id "first." This is just going to be the first box, and then it says if there is no dynamic sidebar called 'sidebar-3,' meaning if no one put anything into the widgetized area in 'sidebar-3,' then instead you are going to display this aside widget that says Hello? So if I save this and I go to my front page now and reload it, you will see the text Hello? here at the bottom.

So this is where you want that list of items to display. So the next step is to add a list of items instead of just the text Hello? in here. So if we go back to the code snippets, I've created another code snippet that has an actual list in it. So if we copy out all that code and paste it in place of what we already copied out and pasted in, you now have the exact same statement, still has the div id="first," but instead of creating just text Hello?, we now creates an aside called widget in which we have a title, Recent Recipes, and we have an unordered list in which we have a dummy content line, in which we have one item that's just dummy content right now, but that shows a permalink and some text.

If I save this and reload the page, you will see we now get the title of the most recent post on this page and we can link to it. Of course, that's not precisely where we want to go, but at least we know it works. Now that we know it works, we can create the two next boxes. So I'll take this code as it is, copy it, and I'll put it in place of this. That's a 'sidebar-4.' So I will just remember it says 'sidebar-4.' I will paste it in, and then of course, this is now not "first," but "second," so I will change it to "second," and I will change second down here and this is 'sidebar-4' and the title is going to be Recent Photos.

And then finally I'll do the same thing with the bottom one. I will paste in this batch of code. This is now "third," "third" at the bottom, and the widget title is Recent Videos. When I save this and reload my front page, you will see at the bottom we have Recent Recipes, Recent Photos, and Recent Videos. Of course, the links don't point quite where we want them to yet, but we have a footer sidebar that shows the boxes where we can put the content we want to display.

By creating a new sidebar-footer.php file, we can take control of what is displayed in the footer-sidebar by default. That way we can take better control of our site and add more information.

Show transcript

This video is part of

Image for Create an Online Portfolio with WordPress
Create an Online Portfolio with WordPress

40 video lessons · 28379 viewers

Morten Rand-Hendriksen
Author

 
Expand all | Collapse all
  1. 6m 28s
    1. Welcome
      58s
    2. Using the exercise files
      3m 54s
    3. Using the code snippets file
      1m 36s
  2. 8m 31s
    1. What is an online portfolio?
      2m 43s
    2. Tour of the finished project
      3m 15s
    3. Setting up a WordPress development environment
      2m 33s
  3. 16m 10s
    1. Creating site architecture
      5m 1s
    2. Creating a child theme
      6m 7s
    3. Creating an external file to manage functions separately from the theme
      5m 2s
  4. 25m 26s
    1. What is a custom post type?
      2m 14s
    2. Setting up a custom post type
      6m 39s
    3. Adding advanced variables to the custom post type
      3m 35s
    4. Advanced custom post type functionalities
      4m 29s
    5. Changing the menu position of the custom post type
      3m 19s
    6. Adding a custom post type icon
      5m 10s
  5. 22m 8s
    1. What are custom taxonomies?
      3m 34s
    2. Setting up a basic custom taxonomy
      2m 52s
    3. Hooking a custom taxonomy to a post type
      3m 13s
    4. Adding advanced variables to a custom taxonomy
      3m 9s
    5. Using hierarchical and nonhierarchical custom taxonomies
      5m 54s
    6. Using custom taxonomies in admin
      3m 26s
  6. 25m 40s
    1. Populating content into the custom post types
      10m 54s
    2. Uploading videos to YouTube
      2m 22s
    3. Embedding YouTube videos in a custom post type
      4m 23s
    4. Uploading videos to WordPress
      8m 1s
  7. 39m 47s
    1. Creating custom post type templates
      6m 50s
    2. Adding taxonomy info to the custom post type template
      9m 13s
    3. Creating conditional custom taxonomy links
      4m 46s
    4. Handling multiple post type templates: Individual templates
      6m 25s
    5. Handling multiple post type templates: Consolidating everything in one file
      6m 21s
    6. Handling multiple post type templates: Making custom post types the default
      6m 12s
  8. 15m 23s
    1. Creating an index page for a custom post type
      8m 10s
    2. Creating a custom taxonomy index page
      7m 13s
  9. 12m 3s
    1. Creating a custom footer sidebar template
      6m 58s
    2. Displaying a list of links to the latest custom post type posts
      5m 5s
  10. 14m 58s
    1. Creating static pages for the front and the blog
      4m 54s
    2. Populating the menu with new index pages
      4m 52s
    3. Creating a contact page with a contact form
      5m 12s
  11. 5m 55s
    1. Including the abstraction layer in other stock themes
      5m 55s
  12. 1m 22s
    1. Next steps
      1m 22s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
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.


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.

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 Create an Online Portfolio with WordPress.

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

Your file was successfully uploaded.

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.