Have you ever redesigned your blog and your new design only allowed a limited space for your “one mile high” blogroll? A friend of mine ran into exactly this problem with his newly redesigned blog.
The really simple solution we came up is resource-friendly while he can keep all of his links. Most probably the best thing of this simple usage of WordPress functions: it’s entirely based on WordPress’ template tags and there is no need for another plugin.
WordPress Template Tags
Our weapon of choice is the wp_list_bookmarks template tag. It comes in handy if you use a new WordPress theme as starting point, which already uses this tag. If not, now it’s the time to get rid of deprecated tags like
To start, open the file where your link-list is located, most probably sidebar.php or footer.php. The default usage for wp_list_bookmarks is:
<?php wp_list_bookmarks(); ?>
Useful parameters: limit and orderby
Remember, we need to limit the output because of the new design while still giving link-love to all of our blog-friends. To achieve this goal, we applied two parameters to the tag:
These two parameters combined provide us with the limited set of randomized links we need. Seven randomized links fit into the available space, so here is the final template tag with two parameters applied:
<?php wp_list_bookmarks('limit=7&orderby=rand'); ?>
Jupp, it’s remarkably simple, but it works exactly as intended.