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;

cpt_taxonomies_register

apply_filters( 'cpt_taxonomies_register', $registered_taxonomies )

Filter the registered taxonomies data.

Parameters
  • $registered_taxonomiesarray

    Array of registered taxonomies

Example:

add_filter('cpt_taxonomies_register', function($registered_taxonomies){
    $registered_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 $registered_taxonomies;
});
This code is an example, add it to theme’s functions.php file or to custom plugin.

cpt_taxonomies_register_labels

apply_filters( 'cpt_taxonomies_register_labels', $registration_labels, $id )

Filter the registered taxonomies labels.

Parameters
  • $registration_labelsarray

    Array of taxonomy labels.

  • $idstring

    Taxonomy registration id.

Example:

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

cpt_taxonomies_register_args

apply_filters( 'cpt_taxonomies_register_args', $registration_args, $id )

Filter the registered taxonomies args.

Parameters
  • $registration_argsarray

    Array of taxonomy args.

  • $idstring

    Taxonomy registration id.

Example:

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