• I have a category that I’ve set to show just one post. I have about 5 posts in the category. When I view the category post, it has a link at the bottom that says Previous, but when I click Previous, it gives me an error rather than showing me the previous post. Any idea how to fix it so the Previous link takes me to the previous post?

    In more detail, here are the steps I’ve taken:

    1. Made category 87 hidden from home page by adding this code above the loop:

    <?php $page = (get_query_var('paged'))
    ? get_query_var('paged') : 1;
    query_posts("cat=-87&showposts=10&paged=$page");
    ?>

    2. Created a category template modeled after archives.php and renamed it category-87.

    3. Placed the following code just above the loop on the category-87 template.

    <?php $page = (get_query_var('paged'))
    ? get_query_var('paged') : 1;
    query_posts("cat=87&showposts=1&paged=$page");
    ?>

    Here’s what you see when you go to category-87.

    There’s just 1 post, so the query_posts code works, but when I click Previous Entries link, it takes me to an error page.

    What code do I need to put in there to make the Previous link take me to the preceding post?

    (By the way, I tried the Custom Query String plugin but it didn’t work at all.)

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter TomJohnson

    (@tomjohnson)

    I was really hoping to get some insight on how to do this.

    I’m trying to accomplish something very similar, and I’m also not having any luck. I get an error page as well.

    I’ve tried the various “previous post” php solutions, but to no avail.

    (I’m hoping by posting this, it’ll get brought back to the foreground, and someone will know how to make this work…)

    Ha! Just found the solution. Well, sort of.

    It doesn’t work on the category page, but it works on the post page, allowing you to navigate to the previous post directly.

    ‘<?php previous_post_link(‘« %link’, ‘Previous post in category: %title’, TRUE); ?>
    <?php next_post_link(‘%link »’, ‘Next post in category: %title’, TRUE); ?>’

    All thanks to ScriptyGoddess; it’s her code. Hope it does the trick for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Previous Link Doesn’t Work for Category with One Post’ is closed to new replies.