Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am building an event manager. One of the template files I have is events-single.php which displays single events. At the bottom of this I have next and previous events using next_post_link and previous_post_link. The problem is that those functions proceed through the events in order of published date rather than event date. (I have a meta key _fulldate setup on the CPT for this). When I was building events-archive.php file I overcame a similar problem by doing something like this

$query = new WP_Query( array ( 
'post_type' => 'events', 
'orderby' => 'meta_value', 
'meta_key' => '_fulldate', 
'order' => 'ASC')
);

However when I try that on events-single.php it makes all the events display on the page.

Ultimatly I want events-single.php to behave like a single page but then allow me control over the query as above. Is this possible or will I have to do a second loop for the Previous and Next links

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

Take a look here: specify meta_key / meta_value condition for prev_post_link and next_post_link

Which ultimately leads to this plugin, which accesses the get_adjacent_post function mentioned above: Ambrosite Next/Previous Post Link Plus

And looks like it would fit your needs by allowing you to specificy a meta_value for the next/prev post hook.

share|improve this answer
    
Thanks for that link - it's the right track all right, but I'm not really understanding how to implement the filters and I cant find a full example anywhere. Anyway It looks to be a bit more complex than I want to get into at the moment and it's not a huge issue on the theme as in context I don't think previous next events will be that important to most people so I'm leaving it out for this version. BTW the theme is for resale so I want to avoid plugins. –  byronyasgur Mar 15 '12 at 23:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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