• Resolved ArielZusya

    (@arielzusya)


    I’ve got a page on one of my sites that should only show certain posts from certain categories. I’ve gotten as far as creating my loop but I think I’m doing something wrong. With this loop it shows only children of cat 5 but it’s not excluding cat 13. It is excluding cat 16. Anyone able to tell me what I’m doing wrong? Thanks in advance! Code to follow.

    -A

    <?php  $cats = get_categories('orderby=id&order=DESC&child_of=5&$category->cat_ID>16&exclude=13&exclude=16');
    		// This is a loop that pulls any special categories
    
    			foreach ($cats as $cat) :
    				echo '<h1>' . $cat->name . '</h1>';
    				query_posts( 'orderby=date&order=ASC&cat='.$cat->term_id );
    				    if (have_posts()) : while (have_posts()) : the_post(); ?>
    					<?php the_content(); ?>
    				    <?php endwhile; endif; wp_reset_query(); ?>
    
    			<?php endforeach; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • You’ve coded the exclude parameter(s) incorrectly. Because you’re passing in exclude twice, the second instance is overriding the first, which is why 16 is being excluded, but not 13. To exclude multiple categories, put them in a comma-separated list, i.e., change it to this: exclude=13,16

    Thread Starter ArielZusya

    (@arielzusya)

    Makes total sense. Thanks for the assist! Problem solved.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘exclude cat redux’ is closed to new replies.