有什么方法可以显示来自Wordpress中自定义分类法特定术语的相关帖子?

时间:2018-07-14 09:42:59

标签: wordpress custom-taxonomy related-posts

我创建一个名为 type 的分类法,该分类法包含3个术语-主题插件托管。每个分类法都有几个职位。我想在单个页面上显示特定的相关帖子。

示例1:当访客阅读“ Avada主题评论”时,我想显示“ 主题”一词中的帖子 示例2:当访客阅读“ Visual Composer评论”时,我想显示“ 插件”一词的帖子

我的查询是:

global $post;
$categories = get_the_category( $post->ID );

$term_ids = array();

foreach( $categories as $individual_field ) {
    $term_ids[] = $individual_field->term_id;
}

$args = array(
    'post_type'             => $post_type,
    'posts_per_page'        => $posts_per_page,
    'category__in'          => $term_ids,
    'post__not_in'          => array( $post->ID ),
);

我该如何更新?

请帮助...

0 个答案:

没有答案