Skip to content

Getting post tags in wordpress

Withing the loop – it will display the post tags

$posttags = get_the_tags();
if ($posttags) {
 foreach($posttags as $tag) {
    echo ''.$tag->name .' ';
 }
}

Outside of the loop – Which will display all of the post tags:

$tags = get_tags();
if ($tags) {
 foreach ($tags as $tag) {
    echo 'name ) . '" ' . '>' . $tag->name.' ';
  }
} 
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments