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!
Post Revisions:
- 16 August, 2010 @ 11:08 [Current Revision] by dan philibin
- 6 August, 2010 @ 4:12 by Ryan Imel
- 25 October, 2008 @ 6:00 by Ryan Imel
Posted October 25, 2008
Andrew said:
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.
on October 25, 2008 at 6:40 am
Dan Philibin said:
@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.
on October 25, 2008 at 11:49 am
Monika said:
I have so many link categories so show link per category per post and so on,
I love the function and its possibilities
Monika
on October 25, 2008 at 1:46 pm
sunny said:
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!
on September 18, 2009 at 12:59 pm
Mihail said:
Thanks a lot.
Very usefull.
on December 30, 2009 at 3:26 pm