Wordpress 从多个分类中获取相关帖子
我有一个名为Videos的自定义帖子类型,每个类型都有几个分类法。我有一个年龄分类法、一个程序类型分类法和一个原始/联合分类法。当我点击一个视频帖子时,我想显示一个列表,其中包含从这三个分类中提取的四个相关帖子。我已经使用下面的代码显示了一个分类法的相关文章,但是是否可以从多个分类法中提取Wordpress 从多个分类中获取相关帖子,wordpress,post,categories,custom-post-type,taxonomy,Wordpress,Post,Categories,Custom Post Type,Taxonomy,我有一个名为Videos的自定义帖子类型,每个类型都有几个分类法。我有一个年龄分类法、一个程序类型分类法和一个原始/联合分类法。当我点击一个视频帖子时,我想显示一个列表,其中包含从这三个分类中提取的四个相关帖子。我已经使用下面的代码显示了一个分类法的相关文章,但是是否可以从多个分类法中提取 <div id="related-posts"> <h3>Related Videos</h3> <?php global $post; $terms = get_t
<div id="related-posts">
<h3>Related Videos</h3>
<?php
global $post;
$terms = get_the_terms( $post->ID , 'video_age', 'string');
$do_not_duplicate[] = $post->ID;
if(!empty($terms)){
foreach ($terms as $term) {
query_posts( array(
'video_age' => $term->slug,
'showposts' => 4,
'caller_get_posts' => 1,
'post__not_in' => $do_not_duplicate ) );
if(have_posts()){
while ( have_posts() ) : the_post(); $do_not_duplicate[] = $post->ID; ?>
<div id="post-<?php the_ID(); ?>" class="related-post">
<?php the_title();?>
<div class="ilc-excerpt">
<?php the_excerpt(); ?>
</div>
</div>
<?php endwhile; wp_reset_query();
}
}
}
?>
</div>
相关视频
您可以根据自己的喜好使用或扩展它:)查看look for tax\u查询