Get tags outside loop

To echo a list of tags from a particular post outside the Loop, you can set $post global, then do a foreach loop to echo the tags as normal. Adding this PHP code to your wordpress theme will display a list of tags outside the loop.



if (is_single()) {
foreach(get_the_tags($post->ID) as $tag) { echo $tag->name . ', '; }

Leave a comment