I need to identify categories by slug when adding a post in wordpress.
Common and functional example:
$post_id = wp_insert_post( array(
'post_author' => 1,
'post_title' => 'titulo',
'post_type' => 'post',
'post_content' => 'desc',
'post_status' => 'publish',
'tax_input' => array(
'categoria' => array(
'1' //categoria identificada por ID
)
)
) );
How do I need it to stay:
$post_id = wp_insert_post( array(
'post_author' => 1,
'post_title' => 'titulo',
'post_type' => 'post',
'post_content' => 'desc',
'post_status' => 'publish',
'tax_input' => array(
'categoria' => array(
'filme' //categoria identificada por slug
)
)
) );
Is there a possibility? The above example did not work for me.