-1

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

I used:

global $post;
the_tags();

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

1
  • 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

0

Use:

get_the_tags();

With the Post $idparameter so it works outside the loop

Source: get_the_tags

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

-2

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;
2
  • 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.