I had a reader request for some help with their blogroll recently. The WordPress blogroll has gone through many changes over the past year, and a lot of the WordPress themes authors out there didn’t update their themes with the new code used to call the blogroll.

The old code still works, but it doesn’t let you take advantage of the new blogroll capabilities.  If you have set up your blogroll with different categories, but noticed that all of them display under a single category, it is probably because your blog’s theme is still using the original code that didn’t allow for much configuration. You’ll probably find something like this:

<?php get_links()' ?>

or

<?php get_links_list()' ?>

If you want a more configurable code, you will want to use something like the following:

<?php wp_list_bookmarks('categorize=1&before=<li>&title_before=<h2>&title_after=</h2>&category_before=</n>&category_before=</n>&after=</li>&orderby=url'); ?>

This code will display your blogroll, but will let you have separate lists for your different blogroll categories. I’ve customized it to display the category title as a Header 2 and use bullet points to display the content, but you can do a variety of things. For more customization options, you’ll want to check out the WordPress List Bookmarks page and adjust the code as needed.

Want automatic updates? Subscribe to our RSS feed or
Get Email Updates sent directly to your inbox!
Digg This | Stumble it | Add to Del.icio.us | | Print This

There Are 24 Responses So Far. »

  1. 1 DeFries
    Wednesday, February 13th, 2008 at 3:30 am

    This makes me wonder about the possibility for two things.
    Would it be possible to have a page layout in your template where you would just list your blogroll as above mentioned (per category)?
    And secondly would it be possible to have your regular blogroll show just the category of blogroll entries you desire depending on the category shown in the main article? This would be on a single post layout.

    I mean, of all places, HackWordpress would be the place to openly wonder about these possibilities right? :)

  2. 2 Kyle Eslick
    Wednesday, February 13th, 2008 at 7:07 am

    @ DeFries – You can certainly do that use the WordPress page template feature. Create a copy of your page.php file and rename it (obviously), then create the page in your page menu and find it in the Page Template drop-down box. I plan to write a tutorial with screenshots here at some point when time permits.

    As for the second part, if I understand what you are saying, then yes I believe so. You should be able to find what you need in the above linked WordPress Link Bookmarks page.

  3. 3 DeFries
    Wednesday, February 13th, 2008 at 10:14 am

    I’ve got the first part down. Worked like a charm, but I am wondering how to get it into columns. Any idea? ( http://www.de-fries.nl/links )

    For the second part, aren’t your blogpost categories different from the blogroll categories? You would have to lock two specific categories together I’m imagining, but I can’t find how to do that in the Codex.

  4. 4 Carlos Carreño
    Friday, February 22nd, 2008 at 11:06 am

    Thanks, your example help me a lot.

  5. 5 Jo
    Sunday, February 24th, 2008 at 11:42 pm

    Thanks! Your code was a big help. =)

  6. 6 Omar
    Sunday, March 9th, 2008 at 1:30 pm

    Thanks! The code works well – took me a few moments to realize the “blogroll” was in index.php in the case of the theme I have been using…..

  7. 7 Mike
    Tuesday, August 26th, 2008 at 7:25 am

    Great article, it solved the exact issue I was facing! I have been using your plugins and hacks a lot lately, they are all VERY helpful, thanks!

  8. 8 Ami Chopine
    Sunday, August 31st, 2008 at 8:14 pm

    Thank you so much!

  9. 9 ORiOn
    Sunday, September 14th, 2008 at 6:03 am

    How can i hide the title?

    Thanks,
    ORiOn

  10. 10 ORiOn
    Sunday, September 14th, 2008 at 6:13 am

    I find out…

    <?php wp_list_bookmarks(’categorize=2&before=&category_before=&category_before=&after=&orderby=url&categorize=0&title_li=’); ?>

    I have just put:
    &categorize=0&title_li=

  11. 11 pero
    Tuesday, October 21st, 2008 at 10:39 am

    Hi, i want to show blogroll only when somebody click on category named “hosting”, but when we click on homepage or some other categories blogroll must disappear, how to do that?

  12. 12 Kyle Eslick
    Tuesday, October 21st, 2008 at 11:05 am

    @ Pero – I would recommend using WordPress conditional tags, then place the blogroll code into the conditional tags.

  13. 13 Mark McWilliams
    Tuesday, October 21st, 2008 at 11:11 am

    Kyle, I don’t suppose you could do a couple of tutorials on conditional tags?! I only ask because I had a little read of it on codex, and went from confused to even more confused! (That is unless you already have some here at WP Hacks, and I’ve just not seen them!)

    Thanks
    Mark

  14. 14 Kyle Eslick
    Tuesday, October 21st, 2008 at 12:21 pm

    @ Mark –

    I did write about them briefly here, but I would recommend you check out a more detailed write up of conditional tags by my friend Leland at Theme lab.

  15. 15 pero
    Tuesday, October 21st, 2008 at 12:32 pm

    i solve problem with this:

  16. 16 Mark McWilliams
    Tuesday, October 21st, 2008 at 6:16 pm

    Thanks for the link Kyle, it’s the kind of thing I’ve been after. Now I can go and have a little play around, and see what I can come up with!… :D

    Thanks
    Mark

  17. 17 TMR
    Sunday, February 15th, 2009 at 11:40 pm

    Awesome! Thank you for posting this!

  18. 18 sterndal
    Thursday, May 28th, 2009 at 6:31 pm

    hi! this post has been very helpful to me. I’ve just started a self-hosted blog and this article helped much. thank you!



Leave A Comment