I'm trying to get a navigation in the events of event manager

the next/previous post links work but they are ordered by creation date instead of event date.

How could it be possible to change this?

1 Answer 1


The function WordPress ultimately uses for this is get_adjacent_post(), which has filters that allow you to modify the query directly. You'd have to modify the JOIN, WHERE and ORDER BY clauses to join the post meta table and order by your custom field.

Another option is the Ambrosite Next/Previous Post Link Plus plugin.

  • To use get_adjacent_post, you would basically need to write your own function, there is no built in way to use it. You can just copy the function from core.trac.wordpress.org/browser/tags/3.1.1/wp-includes/… and then paste that into your functions.php file? I am just learning about this myself Commented Mar 17, 2012 at 17:23
  • 1
    @westondeboer - you don't have to access the function directly, you can add your filters to it and then call next_post_link as you normally would, which will then call get_adjacent_post, applying your filters to the query.
    – Milo
    Commented Mar 17, 2012 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.