• Hi,

    I’d like to disable certain categories so they don’t show in the loop.

    How do I do that?

Viewing 4 replies - 1 through 4 (of 4 total)
  • see https://codex.www.ads-software.com/Template_Tags/query_posts

    insert before WordPress loop

    <?php query_posts(cat='-6,-12,-15'); ?>

    will remove categories 6, 12, 15 from displaying in the loop

    Thread Starter dva10

    (@dva10)

    Thank you for your reply, stvwlf.

    The thing is – I made several if(is_category) loops in my category.php file. Well, see for yourself:

    <?php if ( is_category(1) ) : ?>
          <div id="contentLeftCategory">
          <h1>Category 1</h1>
    <?php query_posts('cat=1'); ?>
    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
           <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
            <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
            <span class="contentLeftPostMeta"><?php the_time('j. F, Y.') ?> | <?php the_category(', ') ?> | <?php comments_popup_link('No comments', '1 comment', '% comments'); ?>
    </span>
           </div><?php endwhile; ?>
    
    <?php next_posts_link('? Older') ?>
    <?php previous_posts_link('Newer ?') ?>
    <?php else: ?>
    <h3>Content not available</h3>
    <p>The content you are looking for is currently not available</p>
    <?php get_search_form(); ?>
    
    		<?php endif; ?>
    	<?php endif; ?>

    There are about six of these loops. And yes, my knowledge of PHP is limited. ??

    I want to avoid the category-id files. So, what I need is a function that displays the default loop if I’m not on one of these categories (11, 16, 21, 12). But, if I do browse one of these categories the loop is disabled.

    please paste the entire code of category.php in a pastebin
    https://wordpress.pastebin.ca/ and post the URL here

    I can’t tell from your code fragment what you are doing or what you are trying to do.

    Thread Starter dva10

    (@dva10)

    https://wordpress.pastebin.ca/1451285

    This is the category.php file. There is some text in my native language tho, sorry for that.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude categories from the Loop?’ is closed to new replies.