我试图在一篇文章中同时定义两个类别。请告诉我哪里做错了。
\'post_author\' => $user_id,
\'post_status\' => \'pending\',
\'post_category\' => array($_POST[\'cat\'],$_POST[\'joblocation\'])
//\'taxonomy\' => \'jobtype\'
$pid = wp_insert_post( $post_information );
wp_set_post_terms( $pid, $_POST[\'cat\'], \'jobtype\', false );
wp_set_post_terms( $pid, $_POST[\'joblocation\'], \'jobscategory\', false );
SO网友:Rituparna sonowal
只需在wp\\u set\\u post\\u terms分类参数中传递带有类别术语的数组。
global $post;
$post_id = $post->ID;//get the current post id
$terms = array(\'term1\',\'term2\');
$taxonomy = \'category\';
$append = false; // or true
wp_set_post_terms( $post_id, $terms, $taxonomy, $append );