I am trying to insert a post with this code:
$my_post = array(
'post_type' => "essays",
'post_title' => 'TEST 3',
//'post_content' => $content,
'post_status' => 'draft',
'post_author' => 1,
//'post_category' => $cat,
'tags_input' => 'TQM,tag',
);
$post_id = wp_insert_post($my_post);
Everythings works ok except the tags, it does not insert any of them. Any idea?
Use the wp_set_object_terms()
function:
http://codex.wordpress.org/Function_Reference/wp_set_object_terms
wp_set_object_terms($post_id , $arrayoftags, $name_of_tag_taxonomy, false);
Good luck
Your post type is essays
. Custom post types do not support tags by default. You'll have to add a tags
taxonomy to them.
http://codex.wordpress.org/Taxonomies
http://codex.wordpress.org/Function_Reference/register_taxonomy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With