How to Exclude post from a category

This is my home page code

here is a feature post section,
i want to exclude post by a category ‘Collage’ in this section …

<?php 
$count = 1;
if (have_posts()) : while (have_posts()) : the_post(); if($count == 1) : ?>


<div id="featurd_post">
<div class="ftrd_image">
<?php woo_get_image('image',455,245,' '.$GLOBALS['align']); ?>  </div>
<div class="fix"></div>
<div class="ftrd_entry">
<h2 class="title">
<a href="<?php the_permalink() ?>" rel="bookmark" title=""><?php   the_title(); ?></a> 
</h2>
<p class="fetrd_entry"><?php dynamic_excerpt(400); ?></p>
<a href="#" title="" class="read_more">(<?php _e('आगे 
पढे ', 'shreshthbharat'); ?>)</a>
</div></div>     
<?php else : ?>

  <--- Rest of post goes here --- > 

<div class="box"><div class="post">
<h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="">
<?php the_title(); ?></a></h2>

Related posts

Leave a Reply

2 comments

  1. To exclude a category you’ll need to modify the query that’s running. Do this using the query_posts() function: http://codex.wordpress.org/Function_Reference/query_posts

    First, you’ll need to get the ID of the category you want to exclude:

    $exclude_category = get_term_by('name', 'collage', 'category');
    

    Then you’ll need add the category exclusion to the query, and pass the new query to query_posts:

    global $wp_query;
    $args = array_merge( $wp_query->query, array( 'category__not_in' => array( $exclude_category) ) );
    query_posts( $args );
    

    Put all this right at the top of the script, just before the loop.

    Hope that works for you!

  2. Try this may be work.. I didnt wrote it but found on wordpress website.

     <?php query_posts($query_string . '&cat=-3,-8'); ?>
     <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
     <div class="post">
    
     <!-- Display the Title as a link to the Post's permalink. -->
     <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    
     <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
     <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
    
      <div class="entry">
        <?php the_content(); ?>
      </div>
    
      <p class="postmetadata">Posted in <?php the_category(', '); ?></p>
     </div> <!-- closes the first div box -->
    
     <?php endwhile; else: ?>
     <p>Sorry, no posts matched your criteria.</p>
     <?php endif; ?>
    

    for more details you can check this link http://codex.wordpress.org/The_Loop#Exclude_Posts_From_Some_Category