samedi 28 février 2015

publish new post via the front-end and adding to it a custom taxonomy term


I have a form which is adding new posts via the front-end using the function wp_insert_post, my problem is when i'm trying to attach the new post to a custom taxonomy term.


this is my code:



$new_post = array(
'post_title' => $title,
'post_content' => $description,
'post_status' => 'pending',
'post_type' => 'post'
);
$pid = wp_insert_post($new_post);
wp_set_object_terms($pid, array('men2', 'women'), 'group');


my custom taxonomy is hirarrchial (like categories).


the problem is that the wp_set_object_terms doesn't add this to the new post.


Any suggestion?





Aucun commentaire:

Enregistrer un commentaire