0

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();
            ?>
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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