Post Navigation Does Not Conform to Query Arguments
-
[ Moderator note: moved to Hacks. ]
I’ve been experimenting with custom queries (by creating new instances of WP_Query) configured for different types of post orderings. I’ve noticed what I believe is a bug in the WordPress core code, but before I submit it as such, I want to make sure I’m understanding things correctly.
I create a new WP_Query configured to order posts by title or name, in ascending order. The query does indeed return the list of posts in correct order. However, the “get_next_post()” and “get_previous_post()” functions still show the posts according to the default ordering (most recent to least recent). I did some digging into these functions and I believe the problem is that everything ultimately ends up going to the “get_adjacent_post()” function in “/wp-includes/link-template.php”.
Well, guess what? This function “get_adjacent_post()” is HARD CODED to override any ordering by an invocation of the apply_filters() function. Here is an excerpt directly from the latest code:
$sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post );
This is taken directly from line 1714 of that file, and is invoked just before the query is actually executed.
I don’t see how I can override this behavior without modifying core source code–which I really don’t want to do.
Maybe I’m misunderstanding how to get my next and previous links to render correctly, but I do think this is a bug.
If someone has a work-around, I’d sure like to hear it!
Thanks,
David
- The topic ‘Post Navigation Does Not Conform to Query Arguments’ is closed to new replies.