Skip to main content
added 4 characters in body
Source Link
jgraup
  • 9.8k
  • 3
  • 32
  • 68

This is working for me on a single page using a template. Just be sure to set next_posts_link( 'Older Entries »', $query$the_query->max_num_pages );.

// 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();

This is working for me on a single page using a template. Just be sure to set next_posts_link( 'Older Entries »', $query->max_num_pages );.

// 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();

This is working for me on a single page using a template. Just be sure to set next_posts_link( 'Older Entries »', $the_query->max_num_pages );.

// 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();
added 153 characters in body
Source Link
jgraup
  • 9.8k
  • 3
  • 32
  • 68

This is working for me. I'm having on a hard time figuring out how yours mightsingle page using a template. Just be differentsure to set next_posts_link( 'Older Entries »', $query->max_num_pages );.

// 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();

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();

This is working for me on a single page using a template. Just be sure to set next_posts_link( 'Older Entries »', $query->max_num_pages );.

// 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();
added 20 characters in body
Source Link
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' ) : '0';'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 »', 0$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();

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' ) : '0';
$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 »', 0 );
    
} else {
    // no posts found
    echo '<h1 class="page-title screen-reader-text">No Posts Found</h1>';
}

// Restore original Post Data
wp_reset_postdata();

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();
Source Link
jgraup
  • 9.8k
  • 3
  • 32
  • 68
Loading