WordPress.org

Forums

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

  1. Alessandro Tesoro
    Member
    Posted 9 months 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
    Member
    Posted 9 months ago #

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

    http://codex.wordpress.org/Pagination#Adding_the_.22paged.22_parameter_to_a_query

  3. Alessandro Tesoro
    Member
    Posted 9 months 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( );
    
    			endwhile;
    
    			next_posts_link('More »');
  4. Alessandro Tesoro
    Member
    Posted 9 months 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
    Member
    Posted 9 months ago #

    Agh,

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

Reply

You must log in to post.

About this Topic