Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I made a related post sidebar widget and im trying to exclude a category from it i tried 'exclude'=>7932 but that doesnt seem to work, is there another way to do this?

            <?php $category = get_the_category();
            $parent = get_cat_id($category[0]->category_parent);
            $parent = $category[0]->cat_id; ?>
            <ul class="recent-widget-container">
            <?php
            $categories = get_the_category($post->ID);
            if ($categories) {
            $category_ids = array();
            foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
            $args=array(
            'category__in' => $category_ids,
            'post__not_in' => array($post->ID),
            'showposts'=>5, // Number of related posts that will be shown.
            'caller_get_posts'=>1,
            'exclude'=>7932,
            );

            $my_query = new wp_query($args);
            if( $my_query->have_posts() ) {
            while ($my_query->have_posts()) {
            $my_query->the_post();
            ?>
            <?php $id = get_the_ID(); ?>

            <?php $image_meta = get_post_meta($id,'image',true); ?>

            <li class="recent-widget-post">
            <div class="recent-widget-img">
            <?php if ( (isset($image_meta)) && ($image_meta != '') ) { 
            woo_image('key=image&width=140&height=80');
            }else{  echo $small_placeholder;}   ?>
            </div>
            <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
            <p><?php get_the_excerpt_limit( 75, '...' ); ?></p>
            <div class="fix"></div>
            </li>            
            <?php
            }
            }
            }
            $post = $orig_post;
            wp_reset_query();
            ?>
share|improve this question
add comment

1 Answer

Use category__not_in => array(7932) instead. http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.