Add a custom taxonomy to your wordpress installation.

Note: This function was tested as part of a simple wordpress plugin based on WordPress Version 5.2.2.

function register_custom_taxonomy_equipment()
  $labels = [
    'name'              => _x('Equipment', 'taxonomy general name'),
    'singular_name'     => _x('Equipment', 'taxonomy singular name'),
    'search_items'      => __('Search equipment'),
    'all_items'         => __('All equipment'),
    'parent_item'       => __('Parent equipment'),
    'parent_item_colon' => __('Parent equipment:'),
    'edit_item'         => __('Edit equipment'),
    'update_item'       => __('Update equipment'),
    'add_new_item'      => __('Add new equipment'),
    'new_item_name'     => __('New equipment name'),
    'menu_name'         => __('Equipment'),

  $args = [
    'hierarchical'      => true,
    'labels'            => $labels,
    'show_ui'           => true,
    'show_admin_column' => true,
    'query_var'         => true,
    'show_in_rest'      => true,
    'rewrite'           => ['slug' => 'equipment'],
  register_taxonomy('equipment', ['post'], $args);

add_action( 'init', 'register_custom_taxonomy_equipment');

About Author

Christian Unnerstall

Christian Unnerstall, founder of devshooin.com, enjoys designing and building things that look nice and work well, whether it's websites or services within the interwebs. Have questions - feel free to reach out to him. Enjoy

Leave a Reply