Support » Plugins and Hacks » exclude a category from query posts

  • Resolved oldbag66


    hi, im making my own dynamic sidebar and i just want to exclude a category from this script, any help would be appreciated:

    <div class="widget">
    <?php query_posts('showposts=10'); ?>
    	<h3>Latest News</h3>
    		<?php while (have_posts()) : the_post(); ?>
    		<li><a href='<?php the_permalink() ?>'><?php the_title(); ?></a></li>
    		<?php endwhile; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • MichaelH


    The template tag, query_posts(), has a cat=-7 argument. Replace the 7 with your category ID.



    ok that makes sense, i actually need to exclude it from this code (sorry my mistake) and not sure how to add the cat exclusion
    <?php wp_list_categories('show_count=1&title_li=<h3>News Categories</h3>'); ?>

    i tried this but it doesnt work, am i close!:

    <?php wp_list_categories('cat=-13&show_count=1&title_li=<h3>News Categories</h3>'); ?>



    The template tag, wp_list_categories(), uses an exclude= argument (with NO minus sign).

    <?php wp_list_categories('exclude=13&show_count=1&title_li=<h3>News Categories</h3>'); ?>


    thats great thank-you very much.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘exclude a category from query posts’ is closed to new replies.