WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

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 like wp_get_attachment_image

So use wp_set_object_terms as you normally would, e.g.:

$id = media_handle_sideload(.... 
    wp_set_object_terms( $id, array(terms...), $taxonomy, $append );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.