Taxonomies

This documentation for the Custom post types plugin for WordPress allows you to customize all features.

To get professional support you need to make a donation to get the PRO version of the plugin.

You can add as many taxonomies as you like, as for the native WordPress public taxonomies (categories and tags), if they are registered as public they will be present in the administrative menus and will be reachable from the frontend (taxonomy archive page).

New taxonomy using UI

Registering and adding a new taxonomy to your WordPress website has never been easier directly from the administration area.

  1. From the “Extend / Manage” menu click on the “Taxonomies” item;
  2. From the “Taxonomies” page at the top click on the “Add taxonomy” button;
  3. Configure the new taxonomy and click on the “Publish” button;
  4. The item relating to the taxonomy created “Sizes” will be added to the assigned post types menu;
  5. Create and publish a “Size” as a blog category;
  6. Set the created taxonomy from the assigned post type;
  7. See the new “Size” in the frontend;

New taxonomy using hook

cpt_register_taxonomies

add_filter('cpt_register_taxonomies', function($taxonomies){
    $taxonomies[] = [
        'id' => 'sizes',
        'singular' => 'Size',
        'plural' => 'Sizes',
        'post_types' => ['product'],
        'args' => [], // Array or query string of arguments for registering a taxonomy.
        'labels' => [] // An array of labels for this taxonomy.
    ];
    // See https://developer.wordpress.org/reference/functions/register_taxonomy/
    return $taxonomies;
});
This code is an example, add it to theme’s functions.php file or to custom plugin.

Manipulation hook

cpt_register_tax_labels_{ID}

add_filter('cpt_register_tax_labels_sizes', function($labels){
    $labels['search_items'] = 'Search sizes';
    // See https://developer.wordpress.org/reference/functions/get_taxonomy_labels/
    return $labels;
});
This code is an example, add it to theme’s functions.php file or to custom plugin.

cpt_register_tax_args_{ID}

add_filter('cpt_register_tax_args_sizes', function($args){
    $args['show_in_rest'] = true;
    // See https://developer.wordpress.org/reference/functions/register_taxonomy/
    return $args;
});
This code is an example, add it to theme’s functions.php file or to custom plugin.

Get custom taxonomies

on post type

[cpt-terms key="sizes" post-id=""] // by default post-id is current post

// or return by PHP function
cpt_terms($key, $post_id);
*** *******