28 January 2008 ~ 16 Comments

Wordpress – Creating a random friends blogroll

Occasionally I’ll receive an e-mail or a blog comment from someone asking me what plugin I use for my random friends blogroll. The answer to that question is I don’t use one. However I thought I’d go ahead and show how it’s done that way I can just point people in this post’s direction the next time the question is asked. Creating the blogroll is really very simple. It just uses functions that are already built into Wordpress.

First of all one of the things I ALWAYS do when working with the Wordpress sidebar is make sure I use HTML comments so that everything is easy to find later when I feel like doing more editing. If you’re not familiar with HTML comments, they’re simple enough to learn and really do save a lot of time when scanning through long pages looking for code you want to edit. For example here’s the HTML comments I use for my random blogroll:

code1.png

Now then let’s move on to creating our blogroll, shall we? I really can’t stand long blogroll lists, so I usually like to display between 5 and 8 links randomly, then create another link which points to a separate page listing everyone in my blogroll. First I’ll show you the code I use, then attempt to break it down so that it makes a little sense. Here is what I currently use in my sidebar:

code2.png

Okay now that you see what it looks like, let’s find out what that all means. Actually the first and last numbers which I have bolded in red are really the most important, so I’ll concentrate on those. The first number (in this case 16) represents the category ID number for your blogroll. For example if you have a category named “friends” which acts as your blogroll, you’ll need to use the ID of that category, in place of my number 16. Finding the category ID number is easy. Login to your Wordpress dashboard and click Blogroll. You should see a table full of your blogroll links. The third column over, called categories, is what you need to focus on.

code3.png

Mouse over the category name for the blogroll you want to include in your random list. You should see the ID number in the status bar of your browser.

code4.png

Now plug that number into the code above. Easy, right? Finally the last number, in my example number 5, represents how many links you want to display in your blogroll. If you want to display 10 random links, then change the number to 10. For more detailed instructions outlining what all the parameters in the code I’ve presented mean, you can check out the Wordpress Codex. You’ll see a warning at the top of the page alerting you that the code has been deprecated and may no longer function in future versions of Wordpress, however I’m using the latest version of Wordpress and the code still works just fine for me.

I’ve uploaded a text file including the code above, if you’d rather copy and paste it as opposed to typing it all out yourself. Click here to download it.

16 Responses to “Wordpress – Creating a random friends blogroll”

  1. Bose Speakers 28 January 2008 at 10:41 pm Permalink

    Very nice little tutorial here. I am going to give this a try tomorrow.

  2. Paula 29 January 2008 at 3:00 am Permalink

    Hee hee hee. I think I’ve asked you this question a couple times. I’m sorry I haven’t gotten you the thing you need for the top-secret project, but I’ve been having a wee bit o’ crapola going on LOL. Soon my artist buddy that rocks!

    Paula’s last blog post..I Heard a Rumour

  3. Christy 29 January 2008 at 10:38 am Permalink

    This is like math for me, which means that no matter how hard I try I’ll never figure it out, lol. It’s a really cool feature though. Hope you’re having fun making movies buddy:) Have a great day! Hugs.

    Christy’s last blog post..Happy 50th Anniversary Lego

  4. Mike 29 January 2008 at 11:03 pm Permalink

    @Bose: Thank you! Good luck with it =)

    @Paula: Haha…I thought of you while writing this post :P Take your time with the thingy! There’s no rush =)

    @Christy: HEhe…One thing I’ll definitely never be teaching here is math :P It’s always good to hear from ya, Christy. Hope you’re doing well! *hugsback*

  5. Speedcat 2 February 2008 at 11:50 pm Permalink

    Mike, you are just way too good at this!!!

  6. Mike 3 February 2008 at 8:51 am Permalink

    LOL, it’s all just a product of trial and error ;P

  7. Paula 7 April 2008 at 6:50 pm Permalink

    Mike, I finally went with a theme that does not use widgets so am having to learn a lot and I finally used this tutorial and I got it working! WHEEE! Thanks buddy.

    Paula’s last blog post..Dear Lisa

  8. Mike 10 April 2008 at 4:38 pm Permalink

    Wheee, glad to be of service :) I’m having a tough time getting your blog to load right now though, so I can check out your new theme :(

  9. Marlene 7 July 2008 at 1:20 pm Permalink

    I googled for random blogroll and glad i found your site. I have just added the code to my sidebar and it works great! The one i’ve been looking for. Thanks a lot…

    Marlene’s last blog post..Feeling Good With My New Theme

  10. pamello 13 July 2008 at 11:05 am Permalink

    thanks a lot! your example really helped!

    pamello’s last blog post..Digest n°1: Una settimana da Google

  11. kyrillos 3 August 2008 at 9:16 pm Permalink

    Thanks for the code!

    kyrilloss last blog post..Philippines’ American Idol Fever: After Daughtry comes Cook


Leave a Reply