Viewers: in countries Watching now:
Learn how to build an advanced portfolio site that showcases various types of content using the free open-source application WordPress. Author Morten Rand-Hendriksen demonstrates creating custom post types, differentiating and classifying content with custom taxonomies, and working with custom post templates. The course also shows how to embed YouTube videos, build index pages, display the latest posts from different custom post types, and hook custom post types into separate themes. Exercise files accompany with the course.
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.
There are currently no FAQs about Create an Online Portfolio with WordPress.
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.