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 );
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 );
Share
Improve this question
edited Jul 25, 2018 at 13:15
Fayaz
9,0172 gold badges33 silver badges51 bronze badges
asked Dec 13, 2015 at 0:37
Varun SridharanVarun Sridharan
2341 gold badge4 silver badges21 bronze badges
3
- Sorry. Without post type you can't create taxonomies. It's required parameter while creating taxonomies. codex.wordpress/Function_Reference/register_taxonomy. Read here for more information – Kvvaradha Commented Dec 13, 2015 at 1:28
- @Kvvaradha ho ok i just need a screen same like Taxonomy page in wp-admin. can you just tell me is there any readymade class to create like that one ? – Varun Sridharan Commented Dec 13, 2015 at 1:32
- 1 I have not seen readymade code for it. But you can develop it. Do this way. Create a custom post type with your taxonomy. Than hide the custom post type complete from the wp-admin menu. Before that copy the url of your taxonomy page. Than hide it. After hiding the custom post type menu complete. With help of menu creator function create a menu with the link which you copied. Than it will be like what you expected. I guess you understood my flows. – Kvvaradha Commented Dec 13, 2015 at 2:45
1 Answer
Reset to default 3It 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().