1

<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?

3

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; } ?>

http://codex.wordpress.org/Function_Reference/get_the_tags

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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