WordPress.org

Ready to get started?Download WordPress

Forums

Excluded categories mean fewer posts om index page? (7 posts)

  1. michaelc
    Member
    Posted 9 years ago #

    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?

  2. michaelc
    Member
    Posted 9 years ago #

    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.

  3. michaelc
    Member
    Posted 9 years ago #

    Bump...

    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).

  4. michaelc
    Member
    Posted 9 years ago #

    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?

  5. absm
    Member
    Posted 9 years ago #

    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.

  6. soupenvy
    Member
    Posted 8 years ago #

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

  7. pressing_questions
    Member
    Posted 8 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.