I have posts which assigned 1 of 2 different categories.
On the single post view i want to show a next and previous link of posts with the SAME category.
This should be straightforward, i've tried using get_previous_post etc but i cannot exclude posts assigned to the other category.
$prevPost = get_adjacent_post(TRUE,'129',TRUE);
where 129 is the id of the category i want to exclude, but this does not work.
The posts are assigned categories correctly i.e. they are not assigned both categories.
The query is as follows
SELECT p.ID FROM wp_posts AS p INNER JOIN wp_term_relationships AS tr ON p.ID = tr.object_id INNER JOIN wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE p.menu_order < '2' AND p.post_type = 'post' AND p.post_status = 'publish' ORDER BY p.menu_order DESC LIMIT 1
As you can see it doesn't reference the category to exclude.
Is this a wordpress bug or am i missing something here?