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

  • 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 – user3492770 Jul 31 '14 at 15:25
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;
  • Now it's showing me the tags of the first post on each post – user3492770 Jul 31 '14 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. – Pieter Goosen Aug 1 '14 at 12:44

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.