How to create a WordPress Template or Theme

September 21, 2006

Step Four: the Sidebar

So now we’ll stumble into the sidebar. The sidebar is actually pretty easy. Ther’es several ways you can accomplish what you want with it. You could do your general static sidebar, where you add your links one by one. That’s perfectly fine. I’ve actually had to do this in some cases, because when you do the dynamic/WordPress way, you’re (unfortunately) stuck with only one class for your list items. I’ve had cases where I needed each list item to have a different class, and when you have that, then you have to stick with hard-coding.

However, most people don’t have this problem. That’s where the coolness of WordPress comes in. Basically, you manage your links in your Administration panel, under (holy crap!) the “Links” area. You just go in, create your new link, add in the URL and voilà! You have your links. You call them, very simply, to your sidebar to make the sidebar.php file look like this:


<div id="sidebar">
<?php get_links_list(); ?>
</div> <!-- closing sidebar div -->

What this will do is output your links that are listed in your Links manager. By default, the list will be generated by name (alphabetical order). But if you prefer to have your links in another order, you can add ‘id’ to that:


<div id="sidebar">
<?php get_links_list('id'); ?>
</div> <!-- closing sidebar div -->

That will output the list by the ID# given to each link. So if you create your links in your manager in a certain order, then WordPress will output your list in that order. A side note: if you would like them to appear in reverse order, simple place an underscore in front of the parameter:


<div id="sidebar">
<?php get_links_list('_id'); ?>
</div> <!-- closing sidebar div -->

There are many other things you can add to your sidebar…archives, calendar, categories, and so on. However, one of the best and simplest methods of updating/controlling your sidebar is by using Widgets. Widgets are utterly awesome. Some people hate them, but I find them very fun and very easy to use.

Pages: 1 2 3 4 5 6 7

View Comments

Sorry, comments are now closed on this post. You may thank the spammers for that one. But if you have any questions, please feel free to email me and ask - maybe it'll make for a good update in a future post. :)