我制作了一个相关的侧边栏小部件,我试图从中排除一个类别,我尝试了“排除”=>7932,但这似乎不起作用,有没有其他方法可以做到这一点?
<?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();
?>