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.' ';
  }
} 

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

DMCA.com Protection Status