I want to display the tags of the posts in my main page.

I used:

global $post;

But it's only showing up for my FIRST page.

  • I really don't get it. When I use the_category, it's displaying the category for all of my posts but it's not working with the_tags Jul 31, 2014 at 15:25

3 Answers 3




With the Post $idparameter so it works outside the loop

Source: get_the_tags

<?php the_tags('Tags: ', ', ', '<br />'); ?> 

This tag will help to view the tag option in all pages. Please check it let me know for any issues.


try this once

$tags = get_tags();
$html = '<div class="post_tags">';
foreach ( $tags as $tag ) {
    $tag_link = get_tag_link( $tag->term_id );

    $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
    $html .= "{$tag->name}</a>";
$html .= '</div>';
echo $html;
  • Now it's showing me the tags of the first post on each post Jul 31, 2014 at 15:23
  • Please explain why this should work and what your code does. Just dumping code is not a good answer and should be avoided. Thanks for your understanding. Aug 1, 2014 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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