lundi 5 octobre 2015

Wordpress wp_set_object_terms is not working for custom taxonomy

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.

     $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. $check_if_save->get_error_message() always returns an "Invalid Taxonomy". I also check the get_taxonomies() but my custom taxonomy is not included. I also register taxonomy manually and follow this link as a solution. But i doesn't work for me.

Any ideas why this happen?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire