Post_per_page => 1 Returning more than one post
-
So I have no idea why this is happening. I have a custom post type called event. I want to just show the most upcoming event on the home page. For some reason, all the events that I have entered to test are being shown. Here is the query that I am using.
<?php $today = date('Ymd',strtotime("now")); $future = date('Ymd',strtotime("+12 months")); $upcoming_args = array ( 'post_type' => 'event', 'post_per_page' => 1, 'meta_key' => 'date', 'meta_compare' => 'BETWEEN', 'meta_type' => 'numeric', 'meta_value' => array($today, $future), 'orderby' => 'meta_value_num', 'order' => 'ASC' ); $upcoming_query = new WP_Query($upcoming_args); if($upcoming_query->have_posts() ): while($upcoming_query->have_posts() ) : $upcoming_query->the_post(); ?> <?php $date = get_field('date'); $starting_time = get_field('starting_time'); $ending_time = get_field('ending_time'); ?> <div class="col-sm-4"> <a href="<?php the_permalink(); ?>"> <div class="homepage-well event align_center"> <h2><?php the_title(); ?></h2> <h3><?php echo $date; ?></h3> <h3><?php echo $starting_time ?></h3> </div> </a> </div> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php else: ?> <p class="lead">No events</p> <?php endif; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Post_per_page => 1 Returning more than one post’ is closed to new replies.