嘿,伙计们,我有这个函数,我需要排除两个类别:81和82。你能帮忙吗?:)
代码
function has_related_same_cat_posts(){
global $post;
$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),
\'posts_per_page\'=> 4, // Number of related posts that will be shown.
\'caller_get_posts\'=>1,
\'orderby\' => \'rand\',
);
$my_query = new wp_query( $args );
if( $my_query->have_posts() ) {
$return = true;
} else {
$return = false;
}
}
return $return;
}