Is there anyway to assign all new posts that have a custom post_type to a specific category? For example, say I have a post_type that is for Actors. Is there anyway to assign any post that is under Actors to a "People" category? (but without displaying the Category box in the WordPress Admin)


you can first remove the category meta box from Actors post type edit screen like this

 function remove_custom_taxonomy()
    remove_meta_box( 'categorydiv', 'custom_post_slug', 'side' );

add_action( 'admin_menu', 'remove_custom_taxonomy' );

then create a function that will add the category on save_post

function default_category($post_id){
     // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;

     // check for post type
    if ('Actors' == $_POST['post_type']) {
            $Default_category_id = '23';
        wp_set_post_terms( $post_id,$Default_category_id , 'category', ture );


hope this helps

  • It appears to be adding the custom post types to the correct category, but when I look on the Categories page in the WordPress admin it says 0. Any ideas why the correct number isn't showing up? – user1462 Jan 31 '11 at 18:29
  • I'm not sure but i think it has to do code, if you paste it here i could get a better idea. by code i mean the register_post_type function and any other custom code in relevance – Bainternet Jan 31 '11 at 18:47
  • I figured it out. I needed to add "capability_type=>'post'" to the register_post_type arguments in order to get it to appear. – user1462 Jan 31 '11 at 19:35
  • glad i could help :) – Bainternet Jan 31 '11 at 20:33

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.