hellorobot.org

Bug in wp_list_bookmarks?

When I first began building out hellorobot.org, modifying the Grid Focus theme, I wanted to be able to feature some of an ongoing list of links – say only the newest 5. Seemed easy.

WordPress has a built-in template function for displaying links, wp_list_bookmarks(), with a decent list of options that can be passed as a URL query string. One of those options is ‘orderby,’ which natch specifies the order in which the links should be displayed. I wanted it to be ordered by date so, as described in the WP documentation, I entered ‘orderby=updated&order=desc.’

It didn’t work.

The Problem

Why not? I didn’t spend too much time looking into this, but I noticed that although the table wp_links in the database has a ‘link_updated’ column of a datetime type, all of the rows in the table had a link_updated value of ‘0000-00-00 00:00:00.’

In other words, an update time and date was not saved for any of the links I created or updated. At all. I double-checked the CMS to see if there was a field I was supposed to fill out, or a box I was supposed to check. I didn’t find one. Did I miss it?

A Simple Solution

Luckily, I don’t anticipate making updates to a link once it’s created. In fact, I want the links to be ordered by creation date more than I want them ordered by most recent update. (I suppose I might update a link by adding a new tag, and, in such an instance, I’d still prefer the featured links on the hellorobot.org homepage to be the newest links.)

To create a list of links ordered by creation date, with newest items first, I used this query string instead: orderby=id&order=desc. This will return a list of the items with the highest link id, where the link id is simply a unique number assigned to each list in the database table. The database automatically increments the ID, so newer links will always have older IDs than newer ones.

Further Thoughts

This is an simple change. Because I wanted content ordered by creation date more than I did ordered by last update, I probably should have used the ID tag all along.

It might not be worth describing in a post like this, but it represents a growing concern I have with WordPress: how well built is it? It’s very popular, certainly, and that’s one of the primary reasons I decided to try using it. But this possible bug is one more item in a lengthening list of worries: the documentation is lacking; the function parameters inconsistent; et cetera. I suspect this particular instance is likely a failing of mine – some setting set incorrectly, perhaps…

Is WordPress reliable and convenient enough to make up for little annoyances, or is it expanding too quickly, sweeping more and more little errors and inconsistencies under its rug?

No Responses

Add your response

Respond to “Bug in wp_list_bookmarks?”