我刚刚在我的函数中注册了以下代码
add_action( \'init\', \'create_resources_taxonomies\', 0 );
function create_resources_taxonomies() {
$labels = array(
\'name\' => _x( \'cat2\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'cat2\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search category\' ),
\'all_items\' => __( \'All category\' ),
\'parent_item\' => __( \'Parent category\' ),
\'parent_item_colon\' => __( \'Parent category:\' ),
\'edit_item\' => __( \'Edit category\' ),
\'update_item\' => __( \'Update Category\' ),
\'add_new_item\' => __( \'Add New Category\' ),
\'new_item_name\' => __( \'New category Name\' ),
\'menu_name\' => __( \'genre\' ),
);
$args = array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'genre\' ),
);
register_taxonomy( \'genre\', array( \'resources\' ), $args );
}
我想在侧边栏中获取类别列表,所以我在侧边栏中添加了以下代码
<?php
$taxonomy = \'genre\';
$orderby = \'name\';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$title = \'\';
$args = array(
\'taxonomy\' => $taxonomy,
\'orderby\' => $orderby,
\'show_count\' => $show_count,
\'pad_counts\' => $pad_counts,
\'hierarchical\' => $hierarchical,
\'title_li\' => $title
);
?>
<ul>
<?php wp_list_categories( $args ); ?>
</ul>
但我只收到“无类别”文本。我的代码有什么问题?