• When I say “Show at most: 5 posts” in the Reading option in the dashboard, it only displays 3 posts in the frontpage. I suspect that it’s because of this code (my index.php loop):


    <?php while (have_posts()) : the_post(); ?>
    <?php if ( in_category('5') || in_category('6') ) { ?>
    ...do nothing, haha...
    <?php } else { ?>
    ...poststuff in the loop...
    <?php } ?>

    Right now, in my testblog, I have 2 categories that fall under categories 5 and/or 6, so that seems to be the “missing” 2 (2+3=5, yay). Is there any way I can hide certain categories from the frontpage so that WordPress can also skip their count?

    I think this is a minor issue for me since I simply want to see how things look with different number of posts (as few as possible, perhaps), but if I do choose 1 post, it won’t show anything due to the same reason. It’s kind of weird, don’t you think?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Yeah, that is strange. I think it has something to do with the way WP counts the posts. This plugin might be easier to use:
    https://wp-plugins.net/plugin/solvent/
    Then again, I’ve never used it and don’t know if it won’t do the same thing. :o\

    I’m using query_posts to exclude one category from my home page. query_posts would solve part of your problem in that it doesn’t count the posts from the excluded categories in the amount of posts to the home page. It will still pull up 5 entries on the home page. The beginning of my loop looks like this:
    <?php if (have_posts()) : query_posts($query_string .'&cat=-2'); while (have_posts()) : the_post();

    query_posts doesn’t work well to exclude multiple categories, though. Still, have a look at the Codex page about it because it mentions a method to exclude multiple posts on that page. Give it a shot and see if it works.

    Thread Starter s

    (@sofimi)

    Thanks for all your input; I’ll let you know. (I’m busy with other things so getting that done might be a while ??

    Thread Starter s

    (@sofimi)

    https://dev.wp-plugins.org/file/front-page-cats/trunk/front_page_cats.php

    the Solvent plugin was discontinued, I’m trying the plugin from that link. ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘show at most n posts EXCLUDING certain categories?’ is closed to new replies.