Php 获取术语列表仅获取一个术语
我有一个自定义的帖子类型叫做“Jobs”。自定义帖子类型有一个自定义分类法,称为“位置” 在“职务”页面上,显示职务公告所对应的位置。也就是说,一份工作可能在上海和北京都有职位 为了展示这一点,我写了以下-->Php 获取术语列表仅获取一个术语,php,wordpress,custom-taxonomy,Php,Wordpress,Custom Taxonomy,我有一个自定义的帖子类型叫做“Jobs”。自定义帖子类型有一个自定义分类法,称为“位置” 在“职务”页面上,显示职务公告所对应的位置。也就是说,一份工作可能在上海和北京都有职位 为了展示这一点,我写了以下--> 哦,分类法中的前两个术语似乎没有被识别。我试着重新添加它们,这就解决了问题 <?php echo '<ul class="opp_location">'; echo get_the_term_list( $post->ID, 'location
哦,分类法中的前两个术语似乎没有被识别。我试着重新添加它们,这就解决了问题
<?php
echo '<ul class="opp_location">';
echo get_the_term_list( $post->ID, 'locations', '<li>', ',</li><li>', '</li>' );
echo '</ul>';
?>
add_action( 'init', 'register_taxonomy_locations' );
function register_taxonomy_locations() {
$labels = array(
'name' => _x( 'Locations', 'locations' ),
'singular_name' => _x( 'Location', 'locations' ),
'search_items' => _x( 'Search Locations', 'locations' ),
'popular_items' => _x( 'Popular Locations', 'locations' ),
'all_items' => _x( 'All Locations', 'locations' ),
'parent_item' => _x( 'Parent Location', 'locations' ),
'parent_item_colon' => _x( 'Parent Location:', 'locations' ),
'edit_item' => _x( 'Edit Location', 'locations' ),
'update_item' => _x( 'Update Location', 'locations' ),
'add_new_item' => _x( 'Add New Location', 'locations' ),
'new_item_name' => _x( 'New Location', 'locations' ),
'separate_items_with_commas' => _x( 'Separate locations with commas', 'locations' ),
'add_or_remove_items' => _x( 'Add or remove locations', 'locations' ),
'choose_from_most_used' => _x( 'Choose from the most used locations', 'locations' ),
'menu_name' => _x( 'Locations', 'locations' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'show_admin_column' => true,
'hierarchical' => true,
'rewrite' => true,
'query_var' => true
);
register_taxonomy( 'locations', array('job'), $args );
}