0

I'm creating a custom post type by adding the add_action( 'init', 'create_radiotalks' ); text to the functions.php page:

add_action( 'init', 'create_radiotalks' );

function create_radiotalks() {
    register_post_type( 'radiotalks',
        array(
            'labels' => array(
            'name' => __( 'Radio Talks' ),
            'singular_name' => __( 'Radio Talk' ),
            'add_new' => __( 'Add New' ),
            'add_new_item' => __( 'Add New Radio Talk' ),
            'edit' => __( 'Edit' ),
            'edit_item' => __( 'Edit Radio Talk' ),
            'new_item' => __( 'New Radio Talk' ),
            'view' => __( 'View Radio Talk' ),
            'view_item' => __( 'View Radio Talk' ),
            'search_items' => __( 'Search Radio Talks' ),
            'not_found' => __( 'No radio talks found' ),
            'not_found_in_trash' => __( 'No radio talks found in Trash' ),
            'parent' => __( 'Parent Radio Talk' ),
),
            'public' => true,
        )
    );
}

when entering the add new radio talk info, I would like to add the applicable categories and tags, but they do not show up in the admin side bar? How do I make the categories/tags available to my custom post type? thanks for your help.

-don

2

By adding the 'taxonomies' argument:

'public' => true,
'taxonomies' => array( 'category', 'post_tag' ),
1

or by register taxonomy:

<?php
register_taxonomy_for_object_type('category', 'radiotalks');
register_taxonomy_for_object_type('post_tag', 'radiotalks');
  • thanks for your response, Marcin. This site's really helping me flesh out what's possible w/wordpress. – don de lion Mar 10 '11 at 6:45
  • Is there any benefit to Marchin's approach vs. scribu's above? or is it just semantics? – don de lion Mar 10 '11 at 7:05
  • The 'taxonomies' method is just a shortcut for register_taxonomy_for_object_type(). – scribu Mar 10 '11 at 7:21

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.