Class: WP_Taxonomy

Core class used for interacting with taxonomies.


Properties

Name Type(s) Default Value Summary
name string Taxonomy key.
label string Name of the taxonomy shown in the menu. Usually plural.
labels object An array of labels for this taxonomy.
description string A short descriptive summary of what the taxonomy is for.
public boolean Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users.
publicly_queryable boolean Whether the taxonomy is publicly queryable.
hierarchical boolean Whether the taxonomy is hierarchical.
show_ui boolean Whether to generate and allow a UI for managing terms in this taxonomy in the admin.
show_in_menu boolean Whether to show the taxonomy in the admin menu.

If true, the taxonomy is shown as a submenu of the object type menu. If false, no menu is shown.

show_in_nav_menus boolean Whether the taxonomy is available for selection in navigation menus.
show_tagcloud boolean Whether to list the taxonomy in the tag cloud widget controls.
show_in_quick_edit boolean Whether to show the taxonomy in the quick/bulk edit panel.
show_admin_column boolean Whether to display a column for the taxonomy on its post type listing screens.
meta_box_cb boolean | callable The callback function for the meta box display.
object_type array An array of object types this taxonomy is registered for.
cap array Capabilities for this taxonomy.
rewrite array | false Rewrites information for this taxonomy.
query_var string | false Query var string for this taxonomy.
update_count_callback callable Function that will be called when the count is updated.
show_in_rest boolean Whether this taxonomy should appear in the REST API.

Default false. If true, standard endpoints will be registered with respect to $rest_base and $rest_controller_class.

rest_base string | boolean The base path for this taxonomy's REST API endpoints.
rest_controller_class string | boolean The controller for this taxonomy's REST API endpoints.

Custom controllers must extend WP_REST_Controller.

_builtin boolean Whether it is a built-in taxonomy.

Methods

WP_Taxonomy:: __construct( string $taxonomy, array | string $object_type, array | string $args = array() )

Constructor. Since 4.7.0.

Arguments

Name Type(s) Default Value Description
$taxonomy string

Taxonomy key, must not exceed 32 characters.

$object_type array | string

Name of the object type for the taxonomy object.

$args array | string

Optional. Array or query string of arguments for registering a taxonomy. Default empty array.


WP_Taxonomy:: add_hooks( )

Registers the ajax callback for the meta box. Since 4.7.0.


WP_Taxonomy:: add_rewrite_rules( )

Adds the necessary rewrite rules for the taxonomy. Since 4.7.0.


WP_Taxonomy:: remove_hooks( )

Removes the ajax callback for the meta box. Since 4.7.0.


WP_Taxonomy:: remove_rewrite_rules( )

Removes any rewrite rules, permastructs, and rules for the taxonomy. Since 4.7.0.


WP_Taxonomy:: set_props( array | string $object_type, array | string $args )

Sets taxonomy properties. Since 4.7.0.

Arguments

Name Type(s) Default Value Description
$object_type array | string

Name of the object type for the taxonomy object.

$args array | string

Array or query string of arguments for registering a taxonomy.


WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.