Recently, they helped me a lot to create a list of upcoming events (see. Displaying upcoming events (including today's event) here? ), As a result, my pagination using WP Pagenavi has been violated.
At the moment, when you click on page 2, it just shows the same entries as the first page. Although the URL does change to page / 2 pages / 3, etc.
I have this in my functions.php file:
function filter_where( $where = '' ) { $where .= " AND post_date >= '" . date("Ymd") . "'"; return $where; } add_filter( 'posts_where', 'filter_where' ); $query = new WP_Query( array( 'post__not_in' => array(4269), 'paged' => get_query_var('paged'), 'post_type' => 'whatson', 'exclude' => '4269', 'post_status' => 'future,publish', 'posts_per_page' => 20, 'order' => 'ASC' ) ); remove_filter( 'posts_where', 'filter_where' );
My loop is as follows:
<?php while ( $query->have_posts() ) : $query->the_post(); ?> // content <?php endwhile; <?php if (function_exists('wp_pagenavi')) { wp_pagenavi( array( 'query' => $query ) ); } ?>
source share