Skip to main content
2 of 4
added 20 characters in body
jgraup
  • 9.8k
  • 3
  • 32
  • 68

This is working for me. I'm having a hard time figuring out how yours might be different.

// set the "paged" parameter (use 'page' if the query is on a static front page)
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : '1';
$args = array (
    'nopaging'               => false,
    'paged'                  => $paged,
    'posts_per_page'         => '5',
    'post_type'              => 'post',
);

// The Query
$query = new WP_Query( $args );

// The Loop
if ( $query->have_posts() ) {

    previous_posts_link( '« Newer Entries' );

    while ( $query->have_posts() ) {
        $query->the_post();
        echo '<div class="news-item">';
            // post stuff here
                echo '<h1 class="page-title screen-reader-text">' . the_title() . '</h1>';
        echo '</div>';
    }

    next_posts_link( 'Older Entries »', $query->max_num_pages );
    
} else {
    // no posts found
    echo '<h1 class="page-title screen-reader-text">No Posts Found</h1>';
}

// Restore original Post Data
wp_reset_postdata();
jgraup
  • 9.8k
  • 3
  • 32
  • 68