Support » Fixing WordPress » Excluded categories mean fewer posts om index page?

  • Hello again…

    Just noticed that when I use the code from the Codex to exclude a category from my index page, the index page displays fewer posts.

    For example, I have 5 posts per page set in Admin. I just posted five posts to the category I’m excluding, and my index page is now blank! (Imagine how I freaked out before I figured out what’s happening!)

    If I set my posts per page higher, I then start seeing my earlier posts in other categories. The easy answer is to set posts per page very high, but this will make my archive pages and RSS feeds very long (curiously, the feeds aren’t affected, which might be a clue to how I can fix the index page).

    Any ideas?

Viewing 6 replies - 1 through 6 (of 6 total)
  • I spoke too soon – the RSS feed suffers from the same issue.

    This could be a real problem – the excluded category could be very active.


    Considering how messy it is to divert a category for a “side blog,” I’m thinking that the only way to not mess up my home page is to do a complete second WordPress installation just for the side blog, and bring in the stuff from that blog via RSS.

    Upside: I can set up e-mail blogging for the side blog only.

    Downside: more draining for the server, since I’ll have to use absolute paths to grab the XML (I tried working with relative paths in aggrss, but they don’t seem to take).

    Bump (it was the weekend when I posted my question)…

    Any way to tell WP to not count excluded articles against a page’s posts-per-page count?

    Bump (once again)

    I haven’t found an answer to this issue in another forum’s message, so here my trick to avoid that problem.

    1. define the number of post you want to show
    2. be sure you have a least that number of posts in total in your blog (not counting the category you want to exclude)
    3. the trick:

    – replace <?php while (have_posts()) : the_post(); ?> by
    <?php$items_count=0; while ($items_count<20) : the_post(); ?>

    – replace <?php endwhile; ?> by
    <?php $items_count++; endwhile; ?>

    For the feed, the trick is a little bit different, edit your feed files (wp-rss2.php, wp-rss.php, wp-atom.php):
    – replace <?php $items_count++; if (($items_count == get_settings(‘posts_per_rss’)) && empty($m)) { break; } } } ?>
    by <?php $items_count++; if (($items_count == 20) && empty($m)) { break; } } } ?>

    20 is the value chosen for the number of posts, just chose your value.

    Anyone find a better solution to this? Tried the one above, didn’t quite get correct results.

    same problem. the funny part:

    when i echo $items_count, it counts correctly (only the displayed posts as 0, 1, 2 – but then it breaks, although posts_per_rss is set to 24.

    any hint?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Excluded categories mean fewer posts om index page?’ is closed to new replies.