我有一个自定义的帖子类型,叫做'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 );
}发布于 2013-06-25 14:08:50
Ohp,似乎分类法中的前两个术语没有被识别。我试着重新添加它们,并修复了它。
https://stackoverflow.com/questions/17290101
复制相似问题