WordPress: Limited Randomized Blogroll without Plugin

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 get_links() or get_links_list().

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:

limit and orderby.

The Function

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.

6 thoughts on “WordPress: Limited Randomized Blogroll without Plugin”

  1. Big thanks!

    Some may say your solution is quite obvious, but before I found your entry I tried a couple of wordpress plugins – yeah, there are more than a couple of WP plugins to achieve exactly what you did!

    So, many thanks for sharing this with us and keeping my plugins clean ;)

  2. I have a question…

    I’m trying to get rid of the extra left side on my page. The listing of “catagories, pages” ect. I would like to have that only in my widgets and not pre-embedded on to my page. Where do I go in the coding to get rid of this? Sorry if this is not the right place to ask… Thank you!

  3. This is exactly what I did to solve my problem as well, as I hate cluttering my blog with links. I simply added a page to my blog specifically for blogrolls, and then under the links blog on my sidebar, I added a “More…” link directed to the blogroll page. Great way to include everyone without looking like a link directory. :p

Comments are closed.