Pagenavi pagination via wp-query in functions.php showing same content for each page

Finally solved this with:

function my_filter_where( $where="" ) {
    global $wp_query;
    if (is_array($wp_query->query_vars['post_status'])) {

        if (in_array('future',$wp_query->query_vars['post_status'])) {
        // posts today into the future
        $where .= " AND post_date > '" . date('Y-m-d', strtotime('now')) . "'";
        }
    }
    return $where;
}
add_filter( 'posts_where', 'my_filter_where' );

And:

<?php
$wp_query = array(
        'post__not_in' => array(4269),
        'paged' => get_query_var('paged'),
        'post_type' => 'whatson',
        'exclude' => '4269',
        'posts_per_page' => 20,
        'order' => 'ASC',
        'orderby' => 'date',
        'post_status' =>array('future','published'));
query_posts($wp_query);
?>

                    <?php 
                    if ($wp_query->have_posts()) {
                    while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
                        Content
                    <?php endwhile; // end of the loop.
                    }  ?>

                    <?php if (function_exists('wp_pagenavi')) { wp_pagenavi( array( 'query' => $wp_query ) ); } ?>

Leave a Comment