300x250 WordPress Blogroll Code: Separating Your Categories

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!
  • Print This
  • Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Connect with Kyle on Twitter or Google+!

    There Are 25 Responses So Far »

    • Pingback: Technology Talk - 12/30/2007

    • http://www.de-fries.nl DeFries

      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? :)

    • http://kyleeslick.com Kyle Eslick

      @ 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.

    • http://www.de-fries.nl DeFries

      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.

    • Pingback: MT 4.1 vs. WordPress at Pocagoolie

    • Carlos Carreño

      Thanks, your example help me a lot.

    • Jo

      Thanks! Your code was a big help. =)

    • Omar

      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…..

    • Pingback: Wordpress Plugin Centre - Wordpress trick - WordPress Themes Tips and Tricks

    • Pingback: Compilation of WordPress Hacks

    • Mike

      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!

    • http://amichopine.com Ami Chopine

      Thank you so much!

    • Pingback: Top 30 Most Wanted Wordpress Tricks and Hacks | Make Money Blogging Experiment

    • Pingback: 100+ Killer Wordpress Resources | Steffan Antonas' Blog

    • http://www.LibertyTuga.info ORiOn

      How can i hide the title?

      Thanks,
      ORiOn

    • http://www.LibertyTuga.info ORiOn

      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=

    • pero

      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?

    • http://kyleeslick.com Kyle Eslick

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

    • http://www.mark-mcwilliams.com Mark McWilliams

      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

    • http://kyleeslick.com Kyle Eslick

      @ 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.

    • pero

      i solve problem with this:

    • http://www.mark-mcwilliams.com Mark McWilliams

      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

    • TMR

      Awesome! Thank you for posting this!

    • sterndal

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

    • http://www.pattayaguides.com Pattaya Guides

      Thank at all, but I need to show link with description anybody can help me.

      Thanks

    • Pingback: Word Press Link question

    • http://adaldesign.com Adal Design!

      Nice, best post I found on the subject.
      If you add code of a full page template using your code it would be even more clear. Took me a few minutes to figure out that I still had to include if (have posts) and the_content tags.

    • http://cdinsky.com Cdinsky

      Very nice. Configurable code, that is.

      Thanx : )

    • http://www.ourwholeheartedfamily.com stephanie

      I am so thankful to have found your help!! I have been looking for this code! Now I need help with the alignment to the left and putting in bullets under each subject/category…any suggestions?

      Thank you!!

    • http://designcreed.biz Livio

      Thanks for the code, i was looking for it.

    • gagandeep

      Thanks Man, you are great. I was searching for this from last week.

    • http://1stblogger.com/ 1stblogger

      I have been using your plugins and hacks a lot lately, they are all VERY helpful, thanks!