• Resolved oldbag66

    (@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'); ?>
    <li>
    	<h3>Latest News</h3>
    	<ul>
    		<?php while (have_posts()) : the_post(); ?>
    		<li><a href='<?php the_permalink() ?>'><?php the_title(); ?></a></li>
    		<?php endwhile; ?>
    	</ul>
    </li>
    </div>
Viewing 4 replies - 1 through 4 (of 4 total)
  • MichaelH

    (@michaelh)

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

    Thread Starter oldbag66

    (@oldbag66)

    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>'); ?>

    MichaelH

    (@michaelh)

    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>'); ?>
    Thread Starter oldbag66

    (@oldbag66)

    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.