我正在每个帖子下面运行一个自定义查询,以从其类别中获取其他帖子。现在我想排除当前帖子。这是我的问题:
<?php // related_posts();
$exclude_post = $post->ID;
$cats = get_the_category();
//$cats[0]->term_id;$cats[1]->term_id; //name
global $post;
$newQuery = new WP_Query(\'posts_per_page=5&orderby=rand&cat=\'.$cats[0]->term_id.\'&post__not_in=\'.array($exclude_post).\'\');
if ( $newQuery->have_posts() ):?>
<ul>
<?php
while ( $newQuery->have_posts() ) : $newQuery->the_post(); ?>
<li>
<a title="<?php the_title();?>" href="<?php the_permalink();?>"><?php the_title();?></a>
</li>
<?php
endwhile;?>
</ul>
<?php
endif;
?>
现在,我的查询显示0个结果。同样,如果我将testwise排除的post设置为1左右。自定义查询中可能出现什么错误?
啦啦队员