So, I’ve been contemplating a (slight) redesign of this site. And one think I’d like to do is get a selection of the links so lovingly stored in WordPress’ Link Manager. Unfortunately, I can show them all, all from a category, or none. What I’d really like to do is pull a few of them at random from the links database. There is at least one plugin out there that does this, but it requires a seperate text file of links. Given WordPress already stores the links in a table for you, there’s no point reduplicating.

So I wrote a plugin to do it. It’s the first plugin I’ve released publically, incidentally.

The plugin adds a new template function to display a user-specified number of links, optionally with their descriptions, in whatever format you desire. The links are pulled from the database randomly. It’s also possible to not have the links displayed in the browser, but simply returned as an associatve array – so you can process them yourself.

From my brief testing, I can see that it works pretty well, though I haven’t really tested the array-returning functionality. Anyhow, there’s more about the plugin on its dedicated page on this site. You can download it from there and read the full documentation. I hope you find it useful. If you’ve got any problems, bug reports – just drop an email to the usual (and obvious) address.

2 comments on this entry.

  • If Else | 5 Jul 2005

    I hate to tell you this but WP already has the functionality to retrieve a set of random links from the links manager:-)

    You can just do:
    get_links(-1, '', '', '', false, 'rand', false, false, 10);

  • Tom | 6 Jul 2005

    Oh humbug.

    Still, it was a fun learning process! Know my way around the wpdb object a bit better, for a start.

    OK, now I’m going to have to write something WordPress doesn’t have already…