WordPress.org

Forums

Can I add a category to a custom post type automatically? (1 post)

  1. dashnc
    Member
    Posted 4 years ago #

    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)?

Topic Closed

This topic has been closed to new replies.

About this Topic