Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to diplay tag link in wordpress

After every post I am displaying tags

<?php
 global $post;
 foreach(get_the_tags($post->ID) as $tag) {
  echo '<li>'.$tag->name.'</li>';
  }
?>

Now I need to display tag not just as text but as a link that would display all posts filtered by given tag, just like on stackoverflow when you click a tag below the question.

  1. How to make it?
  2. What page template will be used to display search results?
like image 872
Captain Comic Avatar asked Feb 22 '11 12:02

Captain Comic


2 Answers

<?php
global $post;
foreach(get_the_tags($post->ID) as $tag)
{
    echo '<li><a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a></li>';
}

What page template will be used to display search results : for the search template you can follow me for the tags template Tag_Template

like image 141
Poelinca Dorin Avatar answered Oct 28 '22 18:10

Poelinca Dorin


<a href="<?php echo get_tag_link($tag_id); ?>">tag name</a>
like image 38
RemoteSojourner Avatar answered Oct 28 '22 19:10

RemoteSojourner