Anyway to assign custom post types to a specific category?

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

Leave a Comment