- This topic has 1 reply, 2 voices, and was last updated 3 months, 1 week ago by .
-
Topic
-
I created a custom taxonomy to organize Media Library.
The code below works for built-in feature of WP such as featured image or Media Library uploader, but does not work with Metabox field.
I’d like to set a default term to files uploaded from cpt post.function set_media_category($post_ID){
if(!empty($_POST[‘post_id’]) && get_post_type($_POST[‘post_id’])==’cpt’){ wp_set_object_terms($post_ID,102,’media_category’); }
else{ wp_set_object_terms($post_ID,103,’media_category’); }
}
add_action(‘add_attachment’,’set_media_category’,30,1);
add_action(‘edit_attachment’, ‘set_media_category’,30,1);
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.