Dodgy Hax

I recently upgraded to WP 2.3, and an old hack I’d done came back to bite me in the arse. What I had was:

$link_cats = $wpdb->get_results(”
SELECT
Distinct
C.cat_id,
C.cat_name
FROM
$wpdb->link2cat As L2C
JOIN
$wpdb->categories As C
On C.cat_id = L2C.category_id
WHERE
C.cat_id <> (category id was here)
“);

But link2cat has been removed. I replaced this, after a bit of hunting, with the (much more sensible):

$link_cats = get_categories(array(“type” => “link”, “exclude” => “(category id was here)”));

This worked fine, but in the following foreach over the results I found where i had $link_cat->cat_id I now needed $link_cat->cat_ID

Leave a Reply

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>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.