WordPress.org

Ready to get started?Download WordPress

Forums

WP-Paginate
Archive Pagination redirects to home page? (10 posts)

  1. ibullock
    Member
    Posted 3 years ago #

    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/

  2. Eric Martin
    Member
    Plugin Author

    Posted 3 years ago #

    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

  3. ibullock
    Member
    Posted 3 years ago #

    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!

  4. ibullock
    Member
    Posted 3 years ago #

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

  5. Eric Martin
    Member
    Plugin Author

    Posted 3 years ago #

    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.

  6. ibullock
    Member
    Posted 3 years ago #

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

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

  7. Eric Martin
    Member
    Plugin Author

    Posted 3 years ago #

    Can you show an example of the link?

  8. ibullock
    Member
    Posted 3 years ago #

    The link for my localhost is:

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

  9. ibullock
    Member
    Posted 3 years ago #

    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.

  10. ibullock
    Member
    Posted 3 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic