[resolved] Pagination nav links vanish when calling only one category (8 posts)

  1. thirdeyetc
    Posted 8 years ago #

    Ok greetings. I really have felt that I've dug through here enough to gather this hasn't been answered, and it's gotta be an easy fix. I just need someone who knows more than me.

    Ok so here's the deal, after reading these two entries:


    I thought my problems were solved. I am excluding categories from my front page. At first as mentioned in the previous threads, the pagination didn't work. (kept showing the same page) So I implemented the fixes in the form of:

    <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    			$recent = new WP_Query("cat=-3,-4,-9,-8,-74&showposts=5&paged=$page");
    			while($recent->have_posts()) : $recent->the_post();?>

    This works fine for the front page. Problem is I duplicated my index.php file then renamed it review.php and used it as a template for a Page called review. It uses the same code as above except the categories displayed are changed to:

    <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    			$recent = new WP_Query("cat=3&showposts=5&paged=$page");
    			while($recent->have_posts()) : $recent->the_post();?>

    This works fine.. five review posts appear as requested. However, now that I have more than 5 posts listed as category 3, the "previous posts" link isn't even appearing at the bottom of the page. Here's the weird thing. I know the pagination is working because when I enter the following url:


    It displays the second page of posts in category 3, and, to boot, the "next posts" link even appears and it works.

    Any ideas or links to point me in the right direction would be appreciated. I am pretty stumped at this point.

  2. moshu
    Posted 8 years ago #

    then renamed it review.php and used it as a template for a Page called review.

    That's your problem. You should never use Pages to display category listings/archive.
    You have the Category_Templates for that purpose.
    Don't mix posts and Pages - and you will be a happy wordpresser...

  3. thirdeyetc
    Posted 8 years ago #

    I was afraid of that, saw some of your comments to that effect elsewhere.

    Can you look at my site real quick: http://www.thirdeyemag.com/wordpress.

    Problem is I like how when they go to the reviews section or gallery section, since it's a page I am able to use:

    <li><a <?php if (is_page('reviews')) echo('class="current" '); ?>href="<?php bloginfo('url'); ?>/reviews/">reviews</a></li>

    So the li is given the current class and can stay highlighted to let them know where they are at.

    Also, my theme doesn't have category templates, so if I've got that link right, I need to modify my archive.php template to category-3.php, then have my navigation link link to that instead?

    What is the quickest fix here, I need to go live with this tonight...

  4. thirdeyetc
    Posted 8 years ago #

    Thanks for the quick response by the way.. shocking.

    Anyway, I think I have ideas but they seem messy. The last issue I have is I really enjoyed using this for my footer navigation:

    <?php wp_list_pages('sort_column=menu_order&depth=1&title_li='); ?>

    It's easy, and pages appeared as links down there automatically. I am worried if I can't just have a Page called review that acts as a redirect to the archive for category 3, then this could get sloppy...


  5. moshu
    Posted 8 years ago #

    archive.ph is fine to display category archives... and you could apply the code above to if is_category('3') etc....

    And just alter manually your wp_list_pages to include a li item that goes to your cat archive.

    Isn't simpler to manipulate one line in the menu code than to struggle to force WP to do things in an un-natural way?

    I wrote about this here.

  6. thirdeyetc
    Posted 8 years ago #

    ::sighs:: you are right of course. Ok, I'll get on this, I think I can get this done within an hour...

    I will also read your article...

    I guess the only other issue was that I had my gallery page displaying posts from two categories (artwork and photography) but I suppose I can make a "gallery" category and just make those subcategories of it...

  7. thirdeyetc
    Posted 8 years ago #

    Article answered all of my questions to a tee. Thanks! Don't I feel stupid now..

    The information combined with the article and your if is_category('3')suggestion will completely solve this problem.

    If I see anyone else asking anything similar on the forum I will be sure to refer them to your excellent article.


  8. moshu
    Posted 8 years ago #

    Thank you - and I am glad it worked for you!

Topic Closed

This topic has been closed to new replies.

About this Topic