我认为这些应该是单独的分类法。类别本身实际上是一种分类法。
您将为每个过滤器/下拉列表创建分类法。这似乎有些过头了,但我认为这将使开发其他功能变得更容易。
将以下方法添加到函数中。php。将“rwc”替换为主题的域:
function add_taxonomy($singular, $plural, $objects) {
$labels = array(
\'name\' => _x( $plural, \'General Name\', \'rwc\' ),
\'singular_name\' => _x( $singular, \'Singular Name\', \'rwc\' ),
\'menu_name\' => __( $plural, \'rwc\' ),
\'parent_item_colon\' => __( \'Parent \'.$singular.\':\', \'rwc\' ),
\'all_items\' => __( \'All \'.$plural, \'rwc\' ),
\'view_item\' => __( \'View \'.$singular, \'rwc\' ),
\'add_new_item\' => __( \'Add New \'.$singular, \'rwc\' ),
\'add_new\' => __( \'Add New \'.$singular, \'rwc\' ),
\'edit_item\' => __( \'Edit \'.$singular, \'rwc\' ),
\'update_item\' => __( \'Update \'.$singular, \'rwc\' ),
\'search_items\' => __( \'Search \'.$plural, \'rwc\' ),
\'not_found\' => __( $singular.\' Not found\', \'rwc\' ),
\'not_found_in_trash\' => __( $singular.\' Not found in Trash\', \'rwc\' ),
);
$args = array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array(\'slug\' => strtolower($singular))
);
register_taxonomy(strtolower($singular), $objects, $args);
}
然后使用它添加分类法。如果要筛选页面,请将“post”替换为“page”
function add_custom_taxonomies() {
$objects = array(\'post\');
add_taxonomy(\'Gender\', \'Genders\', $objects);
add_taxonomy(\'Level\', \'Levels\', $objects);
// .. and so on
}
add_action( \'init\', \'add_custom_taxonomies\', 0 );