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.

 

 

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

Be Sociable, Share!

Leave a comment