Weekend QuickTip: Standardize Blogroll Formatting

6 Comments

One annoying nuance to many WordPress theme developers is how the bookmarks list is formatted by default in WordPress. While all the other lists – categories, pages, and archives – display in a nice, neat, one-level un-ordered list, it seems that the bookmarks tag does it differently. By using an extra parameter within the tag, we can easily fix this problem.

First off, here is the tag that displays a list of bookmarks [Codex Article]:

<?php wp_list_bookmarks(); ?>

Now, let’s try adding the title_li= parameter like we do to all the other tags. Works, right? Not in the way we want it to.

See, technically, it is hiding something – the “Bookmarks” title that would normally appear above the list. On a default set of bookmarks, you’re probably still seeing “Blogroll”, followed by a second-level list of bookmarks in that category. So really, you’re seeing the title of the category these bookmarks are in. You follow?

To un-categorize the bookmarks and just display them as a straight list, add the ‘categorize’ parameter to the tag:

<?php wp_list_bookmarks('categorize=0&title_li='); ?>

By setting the categorize param to 0, or false, you’ll end up with a straight, top-level list of your bookmarks. Ta-da!

6 thoughts on “Weekend QuickTip: Standardize Blogroll Formatting

  1. Nice quick tip Dan. I’m curious though, do you still see a value in Blogrolls? I’m actually slightly surprised that the functionality hasn’t been moved out of core into a plugin as it seems to be something that isn’t really done anymore.

  2. @Andrew I think that how the bookmarks are used has changed over the years. Now that we’re using WordPress to power much more complex sites, you really don’t see a “My Favorite Links” list anymore.

    For instance, we use bookmarks for our paid links. On one of my client’s sites, we use it to link to related news articles.

    I guess bookmarks are just another option to display content now, if you only need a title, link, and short description. Hell, if they had an RSS feed, we’d use them to power our Community section.

  3. Pingback: Using WordPress bookmarks/links more effectively

  4. oh my god. Thank you so much. I’ve tried to find this information for an hours.
    Thank you so much! It helped a lot!

Comments are closed.