我有一个带有多个自定义分类法+元数据库的自定义帖子类型。我使用了来自codex和其他在线资源的多种方法,但似乎都不起作用。我基本上希望在每个自定义帖子页面的标题下显示当前帖子的分类值。这就是我目前所拥有的。。。
In functions.php:
function discography_album_label() {
$labels = array(
\'name\' => _x( \'Labels\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Label\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Labels\' ),
\'all_items\' => __( \'All Labels\' ),
\'parent_item\' => __( \'Parent Label\' ),
\'parent_item_colon\' => __( \'Parent Label:\' ),
\'edit_item\' => __( \'Edit Label\' ),
\'update_item\' => __( \'Update Label\' ),
\'add_new_item\' => __( \'Add New Label\' ),
\'new_item_name\' => __( \'New Label\' ),
\'menu_name\' => __( \'Labels\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => false,
\'rewrite\' => array( \'slug\' => \'label\' ),
);
register_taxonomy( \'discography_album_label\', \'discography\', $args );
}
add_action( \'init\', \'discography_album_label\', 0 );
In single-discography.php
$genreTax = get_taxonomies( \'\', \'names\' );
$terms = wp_get_post_terms($post->ID, $genreTax, array("fields" => "names", "orderby" => "type"));
<p><?php print_r($terms);?></p>
然而,所有这些输出都是:
Array ( [0] => Ska [1] => Reggae [2] => Record Label )
。。。这并没有真正的帮助,因为这是“标签”的值
and 以及“流派”分类法(无法区分哪个是哪个)。我如何才能获得其中一种分类法的值?