0

I've registered a custom post type called 'document', and want to add category support.

I understand that either

register_taxonomy_for_object_type('category','document');

or adding

'taxonomies' => array('category',), 

to my arguments when registering the post type should do the trick, but neither is working. What am I doing wrong?

Full code is below:

$labels = array(
        'name' => _x('Document', 'post type general name', 'creative'),
        'singular_name' => _x('Document', 'post type singular name', 'creative'),
        'add_new' => _x('Add New', 'post type new', 'creative'),
        'add_new_item' => __('Add New Document', 'creative'),
        'edit_item' => __('Edit Document', 'creative'),
        'new_item' => __('New Document', 'creative'),
        'view_item' => __('View Document', 'creative'),
        'search_items' => __('Search Documents', 'creative'),
        'not_found' =>  __('No Documents found', 'creative'),
        'not_found_in_trash' => __('No Documents found in Trash', 'creative'),
        'parent_item_colon' => '',
        'menu_name' => 'Documents'
        );
$args = array(
        'labels' => $labels,
        'taxonomies' => array('category',),  
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'has_archive' => false,
        'hierarchical' => true,
        'menu_position' => 20,
        'menu_icon' => 'dashicons-media-default',
        'supports' => array( 'title', 'editor', 'thumbnail' )
    );
register_post_type( 'document', $args);
1

It appears to be because I was using the Advanced Custom Fields plugin, which has a seperate taxonomy option that was overriding the standard.

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.