Title: Get tags into class?
Last modified: August 22, 2016

---

# Get tags into class?

 *  Resolved [Jason Robinson](https://wordpress.org/support/users/jsrobinson/)
 * (@jsrobinson)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/get-tags-into-class/)
 * Hi there! Thank you for the super-useful plug-in! I am trying to figure out how
   to get the media-tags for a given image as I am looping through my custom callback
   function.
 * I tried something like:
    class=”‘.the_terms( wp_get_post_tags->ID, array( ‘fields’
   => ‘ids’ ) );.'”
 * and it doesn’t work. Is there an easy way to go about this? Is the taxonomy custom
   for media-tags?
 * [https://wordpress.org/plugins/media-tags/](https://wordpress.org/plugins/media-tags/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [Jason Robinson](https://wordpress.org/support/users/jsrobinson/)
 * (@jsrobinson)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/get-tags-into-class/#post-5714453)
 * I should note than the above example was trying to extract the IDs of the tags
   so I could then get the name/slug of each, I’ve also tried:
 * `class="'.the_terms( $post->ID, 'attachment', '', ' ' );.'"`
 *  Thread Starter [Jason Robinson](https://wordpress.org/support/users/jsrobinson/)
 * (@jsrobinson)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/get-tags-into-class/#post-5714467)
 * and this doesn’t work either
 * `class="'.the_terms($post_item->ID,'taxonomy=media-tags','',' ','').'"`
 *  Thread Starter [Jason Robinson](https://wordpress.org/support/users/jsrobinson/)
 * (@jsrobinson)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/get-tags-into-class/#post-5714500)
 * ok, I need to stop copying/paste!
 * `"'.the_terms($post_item->ID,'media-tags','',' ','').'"`
 * is working a lot closer to what I need. Now to get rid of the linkage!
 * I ended up using
    [http://codex.wordpress.org/Function_Reference/wp_get_object_terms](http://codex.wordpress.org/Function_Reference/wp_get_object_terms)
 * and looping through to get the exact output I wanted.
 *  Plugin Author [Paul Menard](https://wordpress.org/support/users/pmenard/)
 * (@pmenard)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/get-tags-into-class/#post-5714502)
 * [@jsrobinson](https://wordpress.org/support/users/jsrobinson/),
 * Thanks for writing. So I see you have the solution to your own question.
 * Correct, the Media-Tags plugin simply creates a custom taxonomy. So you can use
   the WordPress functions as needed.
 * As part of the plugin there are also some template functions you can use. For
   example there is a function ‘the_mediatags()’ which is similar to the WordPress‘
   the_cateogies()’ for the post categories taxonomy and ‘the_tags()’ for the post
   tags taxonomy. Check out the plugin file mediatags_template_functions.php
 * Let me know if you need any more help.
 *  Thread Starter [Jason Robinson](https://wordpress.org/support/users/jsrobinson/)
 * (@jsrobinson)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/get-tags-into-class/#post-5714568)
 * thank you for the pointer for the helper functions, definitely been spending 
   some time in there today 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

 The topic ‘Get tags into class?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/media-tags.svg)
 * [Media Tags](https://wordpress.org/plugins/media-tags/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/media-tags/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/media-tags/)
 * [Active Topics](https://wordpress.org/support/plugin/media-tags/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/media-tags/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/media-tags/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Jason Robinson](https://wordpress.org/support/users/jsrobinson/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/get-tags-into-class/#post-5714568)
 * Status: resolved