<? php /** *Create a custom category *@ param $taxonomy [The name of the taxonomy. This name should not contain Chinese, because it is not for users, but is similar to the role of ID] *@ param $post_type [Which article types are used for the taxonomy, such as post, page, attachment, revision, and nav_menu_item] *@ param $args [detailed below] */ register_taxonomy ($taxonomy, $post_type, $args); ?>
Example of use
$labels = array( 'name'=>__ ('filter tag ', THEME_LANGUAGE), 'singular_name '=>__ ('multiple filter label', THEME_LANGUAGE), 'search_items'=>__ ('Search tag ', THEME_LANGUAGE), 'all_items'=>__ ('All tags', THEME_LANGUAGE), 'menu_name '=>__ ('filter tag', THEME_LANGUAGE), 'edit_item'=>__ ('Edit tag ', THEME_LANGUAGE), 'update_item'=>__ ('Update label ', THEME_LANGUAGE), 'add_new_item'=>__ ('Add tag ', THEME_LANGUAGE), 'new_item_name'=>__ ('new tag value ', THEME_LANGUAGE), 'not_found'=>__ ('No label temporarily ', THEME_LANGUAGE), ); register_taxonomy ('attr', array('post'), array( 'hierarchical' => false, 'labels' => $labels, 'show_ui' => true, 'show_in_rest' => true, 'show_admin_column' => true, 'query_var' => true, 'publicly_queryable' => true, 'public' => false ));

-
Label: The name displayed to the user by the taxonomy, which can use Chinese and other characters -
Labels: nouns displayed to users. This array is used to set the key text displayed to the user. If WordPress is not filled in, it will automatically set it for you (refer to the labels parameter below) -
Public: whether to publish it. If it is published, the foreground archive page will be generated -
Show_ui: Whether to display in the background side management menu -
Show_in_nav_menus: Add a term to the menu page -
Show_tagcloud: Whether the taxonomy displays the components of the tag cloud -
Meta_box_cb: What is the form of the taxonomy selection section displayed in the article editor -
Show_admin_column: whether to display on the data column of background article list -
Hierarchical: displays the form of the taxonomy selection block in the article editor. If it is set to True, it is the classification form (multi choice box), and if it is set to False, it is the label form (text box and add button) [Note: whether the management interface of taxonomy is like "classification" or "label" depends on your hierarchical parameters] -
Update_count_callback: the callback function when the taxonomy changes -
Query_var: the keyword for querying the archive page. The default is the taxonomy name (ID). It's better to keep the default -
Rewrite: pseudo static rule. If set to False, pseudo static will be disabled; You can also set some elements, such as "slug" -
Capabilities: taxonomy permission settings. It's better to keep the default -
Sort: sorting when querying taxonomy articles -
_Builtin: Is this a built-in taxonomy or a user-defined taxonomy. It is better to keep the default or set it to False. This parameter is only useful for WordPress core
-
'name' – the generic name of the classification, usually plural -
'singular_name '– the name of an object of this taxonomy -
'search_items' – Search for item text. The default is __ ('Search Label ') or __ ('Search Category') -
'popular_items' – popular item text. The default is __ ('popular tag ') or null -
'all_items' – All item text. The default is __ ('All Labels') or __ ('All Categories') -
'parent_item' – Parent item text. This string is not used for non hierarchical taxonomies, such as post tags. The default value is null or __ ('Parent Category ') -
'parent_item_colon' – Same as the result parent_item, but: ends with a colon, __ ('parent category: ') -
'edit_item' – Edit the item text. The default is __ ('Edit Label ') or __ ('Edit Category') -
'update_item' – Update the item text. The default is __ ('Update Label ') or __ ('Update Category') -
'add_new_item' – Add new item text. The default is __ ('Add New Label ') or __ ('Add New Category') -
'new_item_name' – New item name text. The default is __ ('new label name ') or __ ('new category name') -
'separate_items_with_commas' – Separate items using comma text in the category item metabox. This string is not used for hierarchical taxonomies. The default value is __ ('Separate label with comma ') or null -
'add_or_remove_items' – Add or delete item text and use it in the metabox when JavaScript is disabled. This string is not used for hierarchical taxonomies. The default value is __ ('Add or Remove Tag ') or null -
'choose_from_most_used' – Select from the most commonly used text used in the taxonomy meta box. This string is not used for hierarchical taxonomies. The default value is __ ('Select from the most commonly used labels') or null -
'menu_name '– Menu name text. This string is the name of the provided menu item. The default value is name
Foreground call
Particular attention