Forums

[resolved] Excluding a category on the homepage is doing something weird... (6 posts)

  1. nando99
    Member
    Posted 2 years ago #

    I'm currently using the code below to exclude a category from the homepage.

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); if (is_home()) if (in_category('32')) continue; ?>

    Lets say I show 10 posts per page, if any of the latest 10 posts are from the category I'm excluding - they dont show. Cool. Great. BUT the full 10 posts wont show either. It's like if 3 of the last 10 posts are from the excluded category, only 7 posts will show. If the next page doesn't in include any posts from the excluded category then it shows 10 posts again.

    I hope that made sense...

    I'd like to always show the right # of posts and still exclude certain category posts - is that possible?

    Thanks in advance,

    nando

  2. alchymyth
    The Sweeper
    Posted 2 years ago #

  3. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Assuming that you're trying to exclude any pages from cat 32 from the home page, try:

    <?php while (have_posts()) : the_post();
    if (in_category('32')) continue;

    You don't need the is_home in index.php.

  4. nando99
    Member
    Posted 2 years ago #

    sorry for the delay in response...

    I just tried:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); if (in_category('14')) continue; ?>

    It shows all posts except posts from category 14 like its suppose to but it still does the same thing.... If its a category I post in alot - the home page looks weird with only like 4 posts...

    Any additional help is appreciated...

    thanks in advance...

  5. MichaelH
    Volunteer
    Posted 2 years ago #

  6. nando99
    Member
    Posted 2 years ago #

    PERFECT!!!

    thanks for the link...

Topic Closed

This topic has been closed to new replies.

About this Topic