我有以下代码,我想为中的每个演员和导演指定一个术语描述$tmdb_actors_arr
和$tmdb_directors_arr
:
// build array
$my_post = array(
\'post_title\' => $tmdb_title,
\'post_name\' => $wp_movie_slug,
\'post_content\' => $tmdb_plot,
\'post_status\' => \'publish\',
\'post_type\' => \'post\',
\'tax_input\' => array(
\'tmdb2wp_year\' => $tmdb_date,
\'tmdb2wp_actor\' => $tmdb_actors_arr,
\'tmdb2wp_director\' => $tmdb_directors_arr
),
);
// insert post built from array above
$post_id = wp_insert_post($my_post);
// instert custom fields
add_post_meta($post_id, \'tmdb_id\', $tmdb_id, true);
add_post_meta($post_id, \'imdb_id\', $tmdb_imdb, true);
add_post_meta($post_id, \'backdrop\', $tmdb_backdrop, true);
add_post_meta($post_id, \'poster\', $tmdb_poster, true);
add_post_meta($post_id, \'original_title\', $tmdb_orig_title, true);
add_post_meta($post_id, \'tagline\', $tmdb_tagline, true);
add_post_meta($post_id, \'trailer\', $tmdb_trailer, true);
add_post_meta($post_id, \'og-image\', $tmdb_poster, true);
add_post_meta($post_id, \'og-title\', $tmdb_title, true);
add_post_meta($post_id, \'og-description\', $tmdb_plot, true);
// insert genres as categories
wp_set_post_terms($post_id, $tmdb_genres_arr, \'category\');
那么,我如何以及在哪里插入导演斯蒂芬·斯皮尔伯格(StephenSpielberg)和演员马龙·白兰度(MarlonBrando)、摩根·弗里曼(MorganFreeman)的术语描述呢?
编辑:
// Movie cast
$i = 0;
while ($i < count($tmdb_cast)) {
$tmdb_actors_arr[] = $tmdb_cast[$i][\'name\'];
$i++;
}
// Movie crew
$i = 0;
while ($i < count($tmdb_crew)) {
if ($tmdb_crew[$i][\'job\'] === "Director") {
$tmdb_directors_arr[] = $tmdb_crew[$i][\'name\'];
}
$i++;
}