Support » Fixing WordPress » Pagination problem after adding query

  • My client wants only the most recent blog to show on a specific category page, with sidebar links to older entries. I tried to handle this by adding a query to a custom category.php page (category-lakewatch.php) in my child theme. That worked fine as far as showing only one post, but then the “older posts” link at the bottom began returning a 404 message. I removed my customization and re-checked the page to make sure that was the cause of the error, and pagination worked fine without the query.

    My initial change to category-lakewatch.php was to add

    <?php query_posts( array ( 'category_name' => 'lakewatch', 'posts_per_page' => 1 ) ); ?>

    just before

    <?php if ( have_posts() ) : ?>

    on line 15 of category.php

    I read the documentation here which discussed pagination problems that could occur when adding a query then and tried these two suggested variations:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
    'category_name' => 'lakewatch', 'posts_per_page' => 1
      'paged' => $paged
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array ( 'category_name' => 'lakewatch', 'posts_per_page' => 1 ) ); ?>

    Both of them worked in as far as the page continued to show a single blog entry but in both cases I’m still getting a 404 when I click “older posts” at the bottom of the page.

    You can see the page in question here if it helps.

    If someone could point out where I’m going wrong, I’d really appreciate it. Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pagination problem after adding query’ is closed to new replies.