I just want to create a custom taxonomy for my plugin use but this should not be linked with any post-type and also I need to add the menu in my custom admin menu (which i have already created).

I tried the following Code:

$args = array(
    'labels'                     => $labels,
    'hierarchical'               => true,
    'public'                     => false,
    'show_ui'                    => 'tools.php',
    'show_in_menu'               => false,
    'show_admin_column'          => false,
    'show_in_nav_menus'          => false,
    'show_tagcloud'              => false,
    'rewrite'                    => false,
    'update_count_callback'      => 'count_aprwc',
);
register_taxonomy( 'aprwc_rating_criteria',array(''), $args );

1
1

It is possible to register a taxonomy without associating a post type by passing null as your argument for the $object_type. Unfortunately, this means that you will still need to associate an object type (post type) to your taxonomy later in order to use it.

register_taxonomy( 'aprwc_rating_criteria', null, $args );

From the documentation:

Setting explicitly to null registers the taxonomy but doesn’t associate it with any objects, so it won’t be directly available within the Admin UI. You will need to manually register it using the ‘taxonomy’ parameter (passed through $args) when registering a custom post_type (see register_post_type()), or using register_taxonomy_for_object_type().

Leave a Reply

Your email address will not be published. Required fields are marked *