‘Posts_per_page’ not working on custom WP_Query
-
Hello,
I have an issue with my WP_Query showing more than one post. Can you please inform me if it would have anything to do with your plugin code.
I’ve researched and developed my code, and test multiple theories
<?php $wpb_next_game = array('post_type'=>'wpcm_match', 'post_status' => 'future', 's' => 'Alderney', 'posts_per_page' => 1 ); $wpb_next_game = new WP_Query($wpb_next_game); if ( have_posts() ) : while ( $wpb_next_game->have_posts() ) : $wpb_next_game->the_post(); $date = date_i18n( get_option( 'date_format' ), strtotime( $post->post_date ) ); $time = date_i18n( get_option( 'time_format' ), strtotime( $post->post_date ) ); $side = wpcm_get_match_clubs( $post->ID ); // badge $badges = wpcm_get_match_badges( $post->ID, 'crest-medium', array( 'class' => 'home-logo' ) ); $badges = wpcm_get_match_badges( $post->ID, 'crest-medium', array( 'class' => 'away-logo' ) ); $format = get_match_title_format(); if( $format == '%home% vs %away%') { $badge = $badges[0]; } else { $badge = $badges[1]; } ?> <div id="next-match" class="row"> <div class="span_6 col"> <h3 class="next-match-home"><?php echo $side[0]; ?></h3> </div> <div class="span_6 col"> <h3 class="next-match-away"><?php echo $side[1]; ?></h3> </div> </div> <div class="row"> <h4 id="next-match-time">Next Match at <?php echo $time; ?> on <?php echo $date; ?></h4> <?php endwhile; wp_reset_postdata(); ?> <!-- end of the loop --> <?php else : ?> <h4 id="next-match-time"><?php _e( 'Sorry, scheduled matches' ); ?></h4> <?php endif; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘‘Posts_per_page’ not working on custom WP_Query’ is closed to new replies.