【发布时间】:2019-06-23 15:04:58
【问题描述】:
我创建了一个自定义帖子类型“stm_media_gallery” 以及此自定义帖子类型中的三个类别。 我想显示与每个帖子关联的类别名称。
<?php $gallery_query = new WP_Query( array('post_type' =>
'stm_media_gallery', 'posts_per_page' => -1) );
if( $gallery_query->have_posts() ) :
while( $gallery_query->have_posts() ) : $gallery_query->the_post(); ?>
--Display post name and its category name
<?php endif; ?>
<?php endwhile; ?>
【问题讨论】:
-
你需要wp_get_post_terms()函数。
-
@Sky 这个工作人员..非常感谢
标签: php wordpress categories posts