'tax_input' => array(
'taxonomy_name' => array(
'term',
'term2',
'term3'
)
); // support for custom taxonomies.
Just change the taxonomy name to the one you want and replace the term placeholders with the category slugs you want.
The Codex weakly implies that you can no longer set the category via wp_insert_post(). However, while I haven’t tested it I would not be surprised if that tax_input argument also works for the category taxonomy, like so:
The argument description in the Codex entry for
wp_insert_post()
has exactly what you need (reformatted).So, per the Codex. Use
wp_set_post_terms()
.For custom taxonomies:
Just change the taxonomy name to the one you want and replace the
term
placeholders with the category slugs you want.The Codex weakly implies that you can no longer set the category via
wp_insert_post()
. However, while I haven’t tested it I would not be surprised if thattax_input
argument also works for thecategory
taxonomy, like so:Worked for me with wp_set_object_terms()