I have a front end post form where users can upload a file with their post that I save as an attachment using media_handle_sideload()
. I need a way to add a term to that attachment so I can show a loop of all specific attachments by a user with that term.
Leave a Reply
You must be logged in to post a comment.
media handle sideload
returns an attachment ID, and attachments are normal posts with the post type ‘attachment’. All the same things apply, featured images parents taxonomies post meta etc albeit with a few attachment oriented functions likewp_get_attachment_image
So use
wp_set_object_terms
as you normally would, e.g.: