post__not_in isn't working in custom Events Query
-
I’m doing two custom queries to show 1 featured event and 4 small events on the homepage of https://careandshare.wpengine.com/
I’m using post__not_in to try and exclude the featured event from the 4 small events (Take a Turkey Day) but it doesn’t seem to be working, even if I remove the variable and use the actual event ID. I’ve also checked and $featuredPost is returning the correct ID. And I’d double checked that the ID *is* the right event ID
<!--Featured Event--> <?php $post_objects = get_field('featured_event'); if( $post_objects ): foreach( $post_objects as $post): setup_postdata($post); ?> <a class="event featured-event" href="<?php the_permalink();?>"> <?php echo wp_get_attachment_image( get_field('event_featured_image'), 'events-large' ); ?> <div class="content"> <h3> <?php the_title();?><br/> <?php echo tribe_get_start_date($post, false, $format = ' F d, Y' ); ?> <span><i class="fa fa-play"></i></span> </h3> <div class="rollover"><?php the_excerpt();?></div> </div> </a> <?php $featuredPost = get_the_ID(); ?> <?php endforeach; wp_reset_postdata(); endif; ?> <!--Regular Events--> <?php $event_query = new WP_Query(array('post__not_in' => array($featuredPost),'posts_per_page'=> 4,'post_type' => 'tribe_events')); if ( $event_query->have_posts() ) { while ( $event_query->have_posts() ) { $event_query->the_post(); ?> <a class="event" href="<?php the_permalink();?>"> <?php echo wp_get_attachment_image( get_field('event_featured_image'), 'events-small' ); ?> <div class="content"> <h3> <?php the_title();?><br/> <?php echo tribe_get_start_date($post, false, $format = ' F d, Y' ); ?> <span><i class="fa fa-play"></i></span> </h3> <div class="rollover"><?php the_excerpt();?></div> </div> </a> <?php } } wp_reset_postdata(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘post__not_in isn't working in custom Events Query’ is closed to new replies.