Support » Themes and Templates » query_posts not excluding category

  • Version: WordPress 2.7.1
    Theme: Thematic Framework
    Installed plugins: All in one SEO Pack, Contact Form 7, Event Calendar, Event Calendar Widget, Executable PHP Widget, Global Translator, NextGEN Gallery, Reveal IDs for WP Admin, Role Manager, Spam Karma 2, To Do List, WP Super Edit, WP Thickbox Integration.

    This code isn’t working. I have WP setup as a CMS and I’m using page templates for certain pages. This template *should* display all the blog posts BUT category 3 (which is displayed on a separate page with it’s own template). Using the Advanced Category Excluder plugin is out because it isn’t as flexible as it would need to be to accommodate for the way I’ve set things up.

    <?php /* Count the number of posts so we can insert a widgetized area */ $count = 1 ?>
    <?php query_posts = ('cat=-10'); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    			<div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
        			<?php thematic_postheader(); ?>
    				<div class="entry-content">
    <?php the_content(''.__('Read More <span class="meta-nav">&raquo;</span>', 'thematic').''); ?>
    				<?php wp_link_pages('before=<div class="page-link">' .__('Pages:', 'thematic') . '&amp;after=</div>') ?>
    				<?php thematic_postfooter(); ?>
    			</div><!-- .post -->


Viewing 5 replies - 1 through 5 (of 5 total)
  • Hmm. I don’t think you’re using query_posts() correctly. Take a look at the codex page for it.

    I think what you’re looking for is:

    <?php query_posts("cat=-3"); ?>

    I don’t know why you were using -10 in there.

    the number is the category number. You don’t have to use 3.

    <?php query_posts("cat=-10"); ?>

    <?php query_posts = ('cat=-10'); ?>

    Has zero effect.

    Anyone else?

    the number is the category number. You don’t have to use 3.

    I know what the number is, but you said in your OP that you’re trying to exclude category 3, so you would have to use 3 to exclude category 3.

    Your original use of query_posts was wrong. It doesn’t use an assignment operator, it is a function. I don’t know why the fix wouldn’t be working for you, but you could try this method.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘query_posts not excluding category’ is closed to new replies.