我买了我的不动产主题,我需要一个用于社区自定义分类的子类别,所以我将层次设置为True。但当我尝试在我的页面中显示它时,社区排在子社区之前。这是它显示的内容:
阿联酋迪拜商业大厦商业湾
而不是
阿联酋迪拜商业湾商业大厦
商业大厦是孩子,商业湾是父母。在父母之前应该先是孩子,对吗?
你能帮帮我吗。
代码如下:
$communitylabels = array(
\'name\' => __( \'Community\', \'contempo\' ),
\'singular_name\' => __( \'Community\', \'contempo\' ),
\'search_items\' => __( \'Search Communities\', \'contempo\' ),
\'popular_items\' => __( \'Popular Communities\', \'contempo\' ),
\'all_items\' => __( \'All Communities\', \'contempo\' ),
\'parent_item\' => __( \'Parent\', \'contempo\' ),
\'parent_item_colon\' => __( \'Parent\', \'contempo\' ),
\'edit_item\' => __( \'Edit Community\', \'contempo\' ),
\'update_item\' => __( \'Update Community\', \'contempo\' ),
\'add_new_item\' => __( \'Add New Community\', \'contempo\' ),
\'new_item_name\' => __( \'New Community\', \'contempo\' ),
\'separate_items_with_commas\' => __( \'Separate Communities with commas\', \'contempo\' ),
\'add_or_remove_items\' => __( \'Add or remove Communities\', \'contempo\' ),
\'choose_from_most_used\' => __( \'Choose from the most used Communities\', \'contempo\' )
);
register_taxonomy( \'community\', \'listings\', array(
\'hierarchical\' => true,
\'labels\' => $communitylabels,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'community\' ),
));
}
if ( ! function_exists( \'community\' ) ) {
function community() {
global $post;
global $wp_query;
$terms_as_text = strip_tags( get_the_term_list( $wp_query->post->ID, \'community\', \'\', \', \', \'\' ) );
echo esc_html($terms_as_text);
}
}
以下是调用自定义分类法时的代码:
// Title
case \'listing_title\' :
echo \'<h2 class="marT5 marB0">\';
ct_listing_title();
echo \'</h2>\';
break;
// location
case \'listing_city_state_zip\' :
echo \'<p class="location marB0">\';
community();
echo \', \';
city();
echo \'\';
country();
echo \'</p>\';