[resolved] WP_Query pagination on custom front page template (5 posts)

  1. Alessandro Tesoro
    Posted 2 years ago #

    Any reason why on the following super simple query http://pastebin.com/fnNW2qSt pagination will not work? The query is placed into a custom page template, set as front page with pretty permalinks set on "post-name" and no other query on the page. The pagination has no effect, the page simply refreshes with the same posts.

    Funny thing is, if i add ?page=2 at the end of the url of the homepage, pagination works just fine.
    Any idea how to solve this?

    Already spent 2 hours on this with no luck... Thank you.

  2. Evan Herman
    Posted 2 years ago #

    Have you added the $paged parameter to your query? It dictates what page you should start/are currently on.


  3. Alessandro Tesoro
    Posted 2 years ago #

    Yes, i did, and it doesn't work. I have also modified the query to reflect the code that is provided on the codex page you linked, and the issue is still there.

    The code now looks like this

    if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
    			elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
    			else { $paged = 1; }
    			query_posts('posts_per_page=3&post_type=listing&paged=' . $paged); 
    			while ( have_posts() ) : the_post();
    			        the_title( );
    			next_posts_link('More »');
  4. Alessandro Tesoro
    Posted 2 years ago #

    Looks like the code of the query isn't the problem, a plugin on my setup is causing the problem. Once the plugin is disabled, the pagination works.

  5. Evan Herman
    Posted 2 years ago #


    what a pain. But glad you were able to resolve it. That can be extremely frustrating.

Topic Closed

This topic has been closed to new replies.

About this Topic