Skip to content

Instantly share code, notes, and snippets.

@jplhomer
Created February 13, 2017 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jplhomer/b75a90183f151f7b4a4415b9a16a5455 to your computer and use it in GitHub Desktop.
Save jplhomer/b75a90183f151f7b4a4415b9a16a5455 to your computer and use it in GitHub Desktop.
Show Taghound Tags on the front-end of a WordPress post.
<?php
// single.php or whatever template you'd like
// 1. Get the ID of the current thumbnail for the post
$attachment_id = get_post_thumbnail_id();
// 2. Get the tags associated to the image
$tags = wp_get_post_terms($attachment_id, 'tmt_tag');
// 3. Collect the names of each tag
$tags = array_map(function($tag) {
return $tag->name;
}, $tags);
?>
<h1><?php the_title(); ?>
<p>
Tags for this image:
<?php
// 4. Print them out where you'd like
echo implode(', ', $tags);
?>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment