Support » Plugin: WP-Paginate » [Plugin: WP-Paginate] Archive Pagination redirects to home page?

  • I’m using the wp-paginate plugin to paginate certain sections of the site I’m currently working on and it’s working fine for everything but the Archive page.

    The first page of the Archive (archive.php in my theme) shows up just fine. But when you click on a page number or the next button, you are taken to the home page(index.php).

    Here’s the code for my query:

    query_posts('s='.$search_term.'&paged='.$thepage.'&cat='.$cat.',&posts_per_page='.$per);

    About the variables: I’ve made a function that forms the query.

    Anyway, I’ve tried this on both my localhost, and a live server and the behaviour is the same (I thought maybe my .htaccess was at fault locally). The URL for archive pages is mysite.com/2011/02/page/2/ but it uses the index template not the archive.

    Any ideas why this could be? Maybe it’s another plugin interfering?

    http://wordpress.org/extend/plugins/wp-paginate/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Eric Martin

    (@emartin24)

    You are missing the paged parameter in your query_posts() function. The following post should answer your question:

    http://wordpress.org/support/topic/plugin-wp-paginate-unable-to-get-page-number-and-advance-1?replies=3#post-1920380

    Unless I’m missing something I don’t believe I am.

    Here’s the code again, this time showing the variable being set.

    $thepage = (get_query_var('paged')) ? get_query_var('paged') : 1;

    query_posts('s='.$search_term.'&paged='.$thepage.'&cat='.$cat.',&posts_per_page='.$per);

    The exact same code is working for paginating my search results, but in the archive the page links (1,2,3 etc.) come up, but take you back to the home page.

    Thanks for your quick reply by the way!

    Update: Clicking on the archive page links actually results in a 404 “page not found”.

    Plugin Author Eric Martin

    (@emartin24)

    Ahh, sorry, I didn’t see the paged parameter.

    Check your Archive page links with the plugin and without and see if there is a difference.

    They’re exactly the same, and also producing a 404.

    Oh, and I’ve tried changing Permalink structure, but still get the same thing.

    Plugin Author Eric Martin

    (@emartin24)

    Can you show an example of the link?

    The link for my localhost is:

    http://localhost/Wordpress/2011/02/page/2/

    Any suggestions for something to look into as a solution?

    This is happening on another site I’ve worked on as well, only on it there are some sections of the archive that paginate perfectly.

    I’ve solved the issue. Here’s what fixed things for me:

    Changed reading settings for “Blog pages show at most” from 10 to 5.

    That solved the 404, but then my query wasn’t working properly so I changed it to look like the follow:

    $year=$wp_query->query_vars['year'];
    
    $month=$wp_query->query_vars['monthnum'];
    
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    query_posts('cat=3&paged='.$page.'&posts_per_page=3&year='.$year.'&monthnum='.$month);

    Hope this helps anyone else looking to paginate their archive!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: WP-Paginate] Archive Pagination redirects to home page?’ is closed to new replies.