Since I use cron jobs for automation I ran into some problems with the taxonomy. Before I used the cron job, the following code used to work:
$custom_tax = array( "project-type" => array( "2" ) ); $mypost = array( 'post_title' => $basicdata["Model"], 'post_type' => "portfolio", 'post_status' => "publish", 'tax_input' => $custom_tax, 'comment_status' => "closed" ); $pid = wp_insert_post($mypost);
I know when I use cron jobs, can't use
wp_insert_post() anymore, but it should work with
wp_set_post_terms(). I didn't really understand how to achieve the same thing with
wp_set_post_terms() by reading the WordPress codex. Would be nice if anyone could help me...