0

I cannot get TAGS to work within my custom post types.

I have the following to establish my custom post type:

function Work() {
    $labels = array(
        'name'               => _x( 'Work', 'post type general name' ),
        'singular_name'      => _x( 'Work', 'post type singular name' ),
        'add_new'            => _x( 'Add New', 'Work' ),
        'edit_item'          => __( 'Edit Work' ),
        'new_item'           => __( 'New Work' ),
        'all_items'          => __( 'All Work' ),
        'view_item'          => __( 'View Work' ),
        'search_items'       => __( 'Search Work' ),
        'not_found'          => __( 'No Work Found' ),
        'not_found_in_trash' => __( 'No Work Found In The Trash' ), 
        'parent_item_colon'  => '',
        'menu_name'          => 'Work'
    );
    $args = array(
        'labels'        => $labels,
        'description'   => 'Holds our Work and Work specific data',
        'public'        => true,
        'menu_position' => 5,
        'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
        'has_archive'   => true,
        'taxonomies' => array('category')

    );
    register_post_type( 'Work', $args );

If I take: 'taxonomies' => array('category') and edit to array('tags') nothing happens. Shouldn't that make tags work with my custom post type?

I also found this code:

function reg_tag() {
         register_taxonomy_for_object_type('post_tag', 'CUSTOM_POST_TYPE');
}
add_action('init', 'reg_tag');

and added it to my functions file as well, but no luck with that either.

Can anyone point me in the right direction?

1

You need to use 'taxonomies' => array( 'post_tag' ) to add tags support for a custom post type, like this:

function Work() {
    $labels = array(
        'name'               => _x( 'Work', 'post type general name' ),
        'singular_name'      => _x( 'Work', 'post type singular name' ),
        'add_new'            => _x( 'Add New', 'Work' ),
        'edit_item'          => __( 'Edit Work' ),
        'new_item'           => __( 'New Work' ),
        'all_items'          => __( 'All Work' ),
        'view_item'          => __( 'View Work' ),
        'search_items'       => __( 'Search Work' ),
        'not_found'          => __( 'No Work Found' ),
        'not_found_in_trash' => __( 'No Work Found In The Trash' ), 
        'parent_item_colon'  => '',
        'menu_name'          => 'Work'
    );
    $args = array(
        'labels'        => $labels,
        'description'   => 'Holds our Work and Work specific data',
        'public'        => true,
        'menu_position' => 5,
        'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
        'has_archive'   => true,
        'taxonomies' => array('category', 'post_tag'),

    );
    register_post_type( 'Work', $args );
}
  • u r welcome! if the answer resolves your issue, then mark it as correct and vote up it :D – Eugene Manuilov Sep 15 '13 at 21:08

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.