• Hi,

    I’m trying to add a normal category to a custom post type automatically.

    This is my code:

    add_action('init', 'myfunc_reg');
    
    function myfunc_reg() {
    
    	$labels = array(
    		stuff
    	);
    
    	$args = array(
    		more stuff,
            'taxonomies' => array('category')
    	  ); 
    
      register_taxonomy_for_object_type('category', 'my_category');
    	register_post_type( 'specials' , $args );
    }

    When I add a new entry for this custom post type I see the categories-selection at the right side. But there is no preselection with “my_category”.

    Is it possible to set this value when I write a new entry automatically (not manually which I have to do at the moment)?

  • The topic ‘Can I add a category to a custom post type automatically?’ is closed to new replies.