我需要检查循环中的当前帖子是否具有与下一篇相同的类别。
while($query->have_posts()){
$query->the_post();
if(category_of_this_post == category_of_the_next_post) //this
//do something
}
下面是一个粗略的设置。
while ( $query->have_posts() ) : $query->the_post();
$next = $query->posts[ $query->current_post + 1];
$current_categories = get_the_category();
$next_post_categories = get_the_category($next->ID);
if ( /* compare $current_categories $next_post_categories */ ) {
}
endwhile;
wp_reset_postdata(); // always reset
请记住以下几点:
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句