Navigation link and pre_get_post
-
Hi all,
I’m working on a website where I need to display also future posts (for an event custom post type).
I managed to display it the way I want and make a nice calendar.But then, on the single view of each event (using single.php), the navigation links only directs to published event and not future ones.
My former pre_get_posts function is
function future_posts( $query ) { if( !is_admin() && $query->is_main_query() ) { $query->set('post_status', array( 'publish','future' )); } } add_action( 'pre_get_posts', 'future_posts' );
I tried to add a line to change the query on single page :
if (is_single() ) { $query->set('post_status', array( 'publish','future' )); }
and i also tried to add the line without conditional tags “is_single()”, but it didn’t change anything.
Thanks for your help!
pierre
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Navigation link and pre_get_post’ is closed to new replies.