get_the_term_list只获取一个术语


get_the_term_list only gets one term

我有一个名为"Jobs"的自定义帖子类型。自定义帖子类型有一个自定义分类法,称为"位置"。

在职位页面上,显示职位发布所对应的位置。即一个职位可能在上海和北京有职位。

为了展示这一点,我写了以下-->

<?php  
    echo '<ul class="opp_location">';
    echo get_the_term_list( $post->ID, 'locations', '<li>', ',</li><li>', '</li>' );
    echo '</ul>';
?>

但是,如果职位发布只有一个术语,则不会输出任何内容。

然而,当我有两个术语时,第二个术语输出。

如果我有三个术语,那么仍然只有第二个术语的输出。

我不太清楚这里发生了什么。我该如何使自定义分类法中属于这篇文章的所有术语都显示出来?

以下是functions.php-->中的分类代码

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 );
}

哦,分类法中的前两个术语似乎没有被识别。我试着重新添加它们,并修复了它。