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.

Popularity: 16% [?]

Looks like you've never been here before! Today is your lucky day. For just the price of a simple mouse click, you can subscribe to this blog's RSS feed!

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

  1. Bose Speakers (1 comments.) Says:

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


  2. Paula (4 comments.) Says:

    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 (5 comments.) Says:

    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 Says:

    @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. Must-See Blog TV | Six 4 Paula Says:

    [...] Tip: Creating a Random Friends Blogroll by Mike/Things By Mike tied with Verify Your Blog on MyBlogLog by Rose/World Outside My [...]


  6. Speedcat (5 comments.) Says:

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


  7. Mike Says:

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


  8. Une blogroll dynamique!!! at Aurelien Bessaguet | un blog web2.fr Says:

    [...] le lien pour pouvoir avoir votre blogroll dynamique in UGC, Web 2.O, blog and blogueur. Feed for this Entry Trackback [...]


  9. la Bogroll va tuer les blogs | Le Journal du Blog Says:

    [...] détaillé sur : http://thingsbymike.com(eng) traduit en français par [...]


  10. Gérer sa blogroll avec WordPress » daria blogue Says:

    [...] Enfin Mike dans son blog ThingsbyMike explique simplement sa gestion aléatoire de sa blog roll en s’appuyant simplement sur le [...]


  11. Paula (4 comments.) Says:

    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


  12. Mike Says:

    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 :(


  13. Some Wordpress SEO Thoughts | Stephan Miller Says:

    [...] I have enough to do this yet. But have about 50 featured links and only display 10 at a time, using the random function and the PHP executable widget or by using this [...]


  14. Marlene (1 comments.) Says:

    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


  15. pamello (1 comments.) Says:

    thanks a lot! your example really helped!

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


  16. kyrillos (1 comments.) Says:

    Thanks for the code!

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


Leave a Reply

Please note: All first time comments are moderated and will show up after admin approval. After that all comments you make on Things by Mike will not be moderated. Furthermore if you come here to make a comment just so you can leave a keyworded link, KNOCK IT OFF. Your comment WILL BE DELETED before it ever shows up on this site, so stop wasting your time and mine. If you want advertising here, you can pay for it, like others appropriately do.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv Enabled