• Creating a taxanomy:

    function create_story_category(){
        register_taxonomy('story_type','story',array(
            'label' => __('Story Category') ,
            'assign_terms' => 'read',
            'edit_terms' => 'edit_posts'
    
        )) ;
    }
    add_action( 'init', 'ndjain_create_story_category' );

    Adding a post via a form to a custom post_type.

    $new_post = array(
                'post_title'    => $title,
                'post_content'  => $description,
                'tax_input' => array('story_type' => $story_cat ),
                'post_status'   => 'pending',
                'post_type' => 'story',
                'post_author' => $authorid
            );
    
            $pid = wp_insert_post($new_post);

    It all works but the line 'tax_input' => array('story_type' => $story_cat ), seems to have no effect. The category is not added to the post

    The var $story_cat is being correctly set btw.
    manually adding the category from the dashboard works.

    Not sure how to debug further

    Help ?

    Thanks

  • The topic ‘wp_insert_post – taxanomy does not get entered..’ is closed to new replies.