Links lists- or blogrolls- can get quite long and laborious for some bloggers. An exceptionally long links list can make your page take longer to load and distract from other important aspects of your sidebar- if you’ve got ads, for instance.
WordPress makes it incredibly easy to to clean up your sidebar and organize your links in a more efficient way. Instead of devoting one sidebar to an entire array of links, you can devote a partial section to it, and rotate through your list.
Many themes now come complete with a links template. So here all you need to do is create a page with “Links List” (or blogroll or whatever you want), select “links” for the template and publish. No need to do anything else. But what if your theme doesn’t come with a links page template?
It’s simple to create a links template. Simply download your theme’s page template- many times it’s simply called “page.php”. At the top of the page add:
<?php
/*
Template Name: Links page
*/
?>
Then look below this snippet
<php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
There you’ll see a php call for the content. This is where you want to put your links list. Highlight
<?php the_content(“<p>__(‘Read the rest of this page »’)</p>”); ?>
(it may be something else, but similar). Replace that portion with
<?php get_links(); ?>
Save the page as “links.php” and upload it to your theme directory.
What if you have different lists for different content types?
It’s simple to organize your links into different catagories on the page. For instance, you may have a links list called “Personal Favorites” and another called “Valuable Resources” and you don’t want to mix the two. What do you do?
First look on your Blogroll page in your admin area. From there go to the tab that says “Categories”. Note the number to the left of your links lists, under “ID”. You may have
“2, Personal Favorites” and “3, Valuable Resources”.
On your links page template, use two distinct tags to call your links. Also, you’ll need to clearly mark which list is which. As an example I’ll do this:
<h2>Personal Favorites</h2>
<?php get_links(2); ?>
Notice that I put a two in the parenthesis. That’s to let the tag know that I want only those links that are in Category 2. Below that I’ll do the same, except I want Category 3 of my links.
<h2>Valuable Resources</h2>
<?php get_links(3); ?>
Of course, you can style the page anyway you want. The important part is the number which is called.
How to incorporate those in your sidebar
Now you want your links to appear in the sidebar, but not all of them at once. To make sure only a certain number of links appear at any given time, you’ll rotate them out in your sidebar. You could use a plugin to do this or you could code it yourself. I’ll show you how to code it yourself.
<h3>Links Rotation</h3>
<ul><?php get_links(’2,3′, ‘<li>’, ‘</li>’, ”, FALSE, ‘rand’, False, False, 15, True); ?>
</ul>
This tells WordPress that I want
* Categories 2 and 3 (’2,3′)
*listed with “<li>” before and “</li>” after
*I don’t want anything between the links (”)
*that I don’t want images (False)
*I want my links to appear randomly (not in any specific order (rand)
*I don’t want to show a description (False)
*I don’t want to show a rating (False)
*that I want the list rotated with a maximum of 15 links showing at one time (15)
*that I do want to show updated (True)
Please note the parameters that require apostrophes and which don’t.
If you want to show your links in order the you can leave that parameter empty (”) and it will default to “id”, which is alphabetical.
To keep your links lists separate, but still in rotation, simply apply this code twice, once with “2″ and once with “3″, then make the maximum number shown reflect a smaller number, such as 7 or 9.
Keeping your sidebar clean and organized keeps attention focused where it should be- on your content. You spend a lot of time picking out the right theme and writing the best content. Utilizing a links page keeps your blog tight and clutter-free.
For more get_links parameters, please visit The WordPress Codex
Comments are closed.