WordPress.org

Forums

WP-PageNavi
[resolved] Custom query pagination on homepage custom page template (4 posts)

  1. Alessandro Tesoro
    Member
    Posted 1 year ago #

    Hello,

    I've got an issue that i've never faced before and although i've followed all the instructions into the sticky topic here on the forum and also googled for a possible a solution i can't figure out why this custom query on the homepage (static front page set to a custom page template).

    The following query is into a custom page template set as static front page

    <?php 
    
    			$args = array( 'post_type' => 'listing', 'posts_per_page' => get_field('listings_per_page','option'), 'paged' => get_query_var('page'));
    
    			$listing_loop = new WP_Query( $args );
    
    			if(
    
    				$listing_loop->have_posts()) :
    
    				while ( $listing_loop->have_posts() ) : $listing_loop->the_post();
    
    					the_title(); echo "<br/><br/>";
    
    				endwhile;
    
    				wp_pagenavi( array( 'query' => $listing_loop ) );
    
    				wp_reset_query();
    
    			 else : ?>
    
    				Nothing here
    
    <?php endif; ?>

    I understand that for homepages i needed to change the "paged" to "page" so i did that, but it won't work it stays on the same page no url change, if i change the "page" back to "paged" and remove the page from being a static front page, the pagination works fine. However i need to set this page template as static front page so this isn't a solution.

    Any idea why it won't work? If it helps, i've set the permalinks to "post name".

    Thank you.

    https://wordpress.org/plugins/wp-pagenavi/

  2. Lester Chan
    Member
    Plugin Author

    Posted 1 year ago #

    You have to use "page" if you are on static front page. If it is not working it might be other thing.

    Since you are using custom post type, it might be related http://wordpress.org/support/topic/custom-post-type-pagination-not-working-2?replies=8#post-5424175

  3. Alessandro Tesoro
    Member
    Posted 1 year ago #

    I just tried that but it doesn't work, and yes i've set "page" in

    get_query_var('page')

    for the "paged" $args key

    Any idea ? Even with wpdebug on, no error messages

  4. Lester Chan
    Member
    Plugin Author

    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.