public add_taxonomy ( array $attachments, array $taxonomies ) | ||
$attachments | array | ids of the attachments created after upload |
$taxonomies | array | array of terms indexed by a taxonomy |
function add_taxonomy($attachments, $taxonomies)
{
foreach ($attachments as $id) {
foreach ($taxonomies as $taxonomy => $terms) {
if (!taxonomy_exists($taxonomy)) {
continue;
}
wp_set_object_terms($id, $terms, $taxonomy);
}
}
}