12th April, 2008

Fix broken Previous/Next Post Links in Wordpress 2.5

Code

Update: this may have been sorted in v2.5.1 - will look into it.

There’s a documented bug in Wordpress 2.5 where the previous_post_link and next_post_link functions stop excluding the categories they’ve been told to.

The bug is not scheduled to be sorted until v2.6 for some weird reason (it’s only a minor change) but in the meantime you can fix it yourself by editing a line in ~/wp-includes/link-template.php

Replace line 557

$posts_in_ex_cats_sql = " AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')';

with the following:

$posts_in_ex_cats_sql = " AND tt.taxonomy = 'category' AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')';

Just need to be careful of this file when upgrading.

Full credit to filosofo on the wordpress forum for this.

No comments yet!

Hide Add

Leave a Reply

Comments RSS Feed for this article
Hide