Ivan Bauer
Ivan Bauer

Reputation: 50

wp_insert_post not saving custom taxonomy on devices

I've faced a weird problem on my wordpress website.

I am using the wp_insert_post on front end to save a custom post type and its custom taxonomy. On PC it saves perfectly the custom taxonomy, but when I try to submit on mobile or ipad, then its not saving it.

here's my code:

$post = array(
    'post_title'=>$_POST['message_title'],
    'post_status'=>'pending',
    'post_type'=>'mondd_el',
    'tax_input'=>array('me_kategoria'=>$cat_id),
    'post_content'=>$_POST['my_message']
);

$postid = wp_insert_post($post);

Thanks

Upvotes: 0

Views: 793

Answers (1)

Labeeb Mohammed
Labeeb Mohammed

Reputation: 76

ARE YOU SURE THE CURRENT USER HAVE CAPABILITY ON WORKING WITH TAXONOMY ? PLEASE CHECK THAT... THIS IS WHAT YOU GET FROM WORDPRESS DOCUMENTATION

"tax_input: Equivalent to calling wp_set_post_terms() for each custom taxonomy in the array. If the current user doesn't have the capability to work with a taxonomy, then you must use wp_set_object_terms() instead."

Upvotes: 3

Related Questions