您好,欢迎访问一九零五行业门户网

请问wordpress中如何获取自定义post_type的分类

我再wordpress 自定义的post type中想要获取当前文章的分类。分类也是自己用register_taxonomy来自定义的。
'wcp_employees' ));?> 'wcp_employees' )); ?>
/images/employees/04.jpg>
=get_post_excerpt()?>
more


这里我也用了query_posts 来指定自己的分类,但是分类还是现实不出来。
回复内容: 我再wordpress 自定义的post type中想要获取当前文章的分类。分类也是自己用register_taxonomy来自定义的。
'wcp_employees' ));?> 'wcp_employees' )); ?>
/images/employees/04.jpg>
=get_post_excerpt()?>
more


这里我也用了query_posts 来指定自己的分类,但是分类还是现实不出来。
找到方法了,用这个function
function custom_taxonomies_terms_links(){ //根据当前文章id获取文章信息 $post = get_post( $post->id ); //获取当前文章的文章类型 $post_type = $post->post_type; //获取文章所在的自定义分类法 $taxonomies = get_object_taxonomies( $post_type, 'objects' ); $out = array(); foreach ( $taxonomies as $taxonomy_slug => $taxonomy ){ $term_list = wp_get_post_terms($post->id, $taxonomy_slug, array(fields => all)); echo $term_list[0]->name; //显示文章所处的分类中的第一个 } return implode('', $out );}
/** *获取分类 **/function deel_category(){ $tag_arr = get_the_category(); foreach($tag_arr as $value){ if(!empty($value)){ echo 'slug,%24value->taxonomy).>'.$value->name.''; } }}
其它类似信息

推荐信息