WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

<a href="<?php echo get_tag_link($tag->id); ?>"><?php echo $tag->name; ?></a>

I was using this to try to list the first tag for a post, and make it so that when you click on that tag you go to a page which lists all of the posts with that tag. Instead, when you click the link it just refreshes the page. I tried going directly to one of our tag pages and it exists but it's totally empty.

How do I get each tag to link to it's tag page and how do I populate tag pages with posts?

share|improve this question

you haven't shown in your code how you get $tag, therefore I include my version (the code has to be in the loop):

<?php $tags = get_the_tags(); 
if( $tags ) foreach( $tags as $tag ) { ?>
<a href="<?php echo get_tag_link($tag->term_id); ?>"><?php echo $tag->name; ?></a>
<?php break; } ?>


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.