5

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 );
  • Sorry. Without post type you can't create taxonomies. It's required parameter while creating taxonomies. codex.wordpress.org/Function_Reference/register_taxonomy. Read here for more information – Kvvaradha Dec 13 '15 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 Dec 13 '15 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 Dec 13 '15 at 2:45
0

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().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.