Wordpress wp_set_object_terms is not working for custom taxonomy

admin

Administrator
Staff member
Hi guys i am trying to add post in WordPress. I used CPT UI to created/register custom post type and custom taxonomies. I used the code below to add my post.

Code:
     $post = array(
        'post_title'    => $title,
        'post_content'  => $description,
        'post_status'   => 'publish',
        'post_type' => 'questions',
     );
     $post_id =  wp_insert_post($post);
     $check_if_save = wp_set_object_terms( $post_id , array(10,11 ), 'question-category' );

But when this code executed
Code:
$check_if_save->get_error_message()
always returns an
Code:
Invalid Taxonomy
. I also check the
Code:
get_taxonomies()
but my custom taxonomy is not included. I also register taxonomy manually and follow this <a href="http://biostall.com/why-a-custom-ta...ned-in-wordpress/comment-page-1#comment-11698" rel="nofollow">link</a> as a solution. But i doesn't work for me.

Any ideas why this happen?