WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Pagination for static page with post loop (2 posts)

  1. zeaks
    Member
    Posted 1 year ago #

    I made a custom page template for Twenty Twelve. The pagination works fine unless I set it as a static homepage, then it will just reload the same posts which is useless because it will be used as a static homepage.

    This is what I'm using to display the pagination.

    <?php /* Display navigation */ ?>
    <?php if (  $wp_query->max_num_pages > 1 ) : ?>
    	<?php twentytwelve_content_nav( 'nav-below' ); ?>
    <?php endif;
     wp_reset_query(); ?>

    Any idea how to make it work for a static homepage as well?

  2. zeaks
    Member
    Posted 1 year ago #

    This is working now, I'll post what I did in case anyone else needs it. Above the query in the page template I added

    global $paged, $wp_query, $wp;
    $args = wp_parse_args($wp->matched_query);
    if ( !empty ( $args['paged'] ) ) {
    	$wp_query->set('paged', $args['paged']);
    	$paged = $args['paged'];
    }

Topic Closed

This topic has been closed to new replies.

About this Topic