投稿 (single.php) で分類法の配列用語が必要です。私は試しています
<?php $term_list = wp_get_post_terms($post->ID, 'agencia', array("fields" => "names")); print_r($term_list); ?>
しかし、html出力は次のとおりです。
Array ( [0] => Agencia 1 )
「Agencia 1」のみを表示したい。2 つの用語がある場合は、「Agencia 1、Agencia 2」を表示する必要があります。
私は何を間違っていますか?
分類の作成:
// カスタムタクソノミーの登録 function custom_taxonomy() {
$labels = array(
'name' => _x( 'Agencias', 'Taxonomy General Name', 'text_domain' ),
'singular_name' => _x( 'Agencia', 'Taxonomy Singular Name', 'text_domain' ),
'menu_name' => __( 'Genre', 'text_domain' ),
'all_items' => __( 'All Genres', 'text_domain' ),
'parent_item' => __( 'Parent Genre', 'text_domain' ),
'parent_item_colon' => __( 'Parent Genre:', 'text_domain' ),
'new_item_name' => __( 'New Genre Name', 'text_domain' ),
'add_new_item' => __( 'Add New Genre', 'text_domain' ),
'edit_item' => __( 'Edit Genre', 'text_domain' ),
'update_item' => __( 'Update Genre', 'text_domain' ),
'separate_items_with_commas' => __( 'Separate genres with commas', 'text_domain' ),
'search_items' => __( 'Search genres', 'text_domain' ),
'add_or_remove_items' => __( 'Add or remove genres', 'text_domain' ),
'choose_from_most_used' => __( 'Choose from the most used genres', 'text_domain' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
);
register_taxonomy( 'agencia', 'post', $args );
}
// Hook into the 'init' action
add_action( 'init', 'custom_taxonomy', 0 );