[resolved] Problems with tags display (3 posts)

  1. rafaht
    Posted 2 years ago #

    I've modified a theme to my like. I created a CSS class to the post tags and searching, I found this: http://codex.wordpress.org/Function_Reference/get_tags. I've adapted this:

    					$tags = get_the_tags();
    					foreach ($tags as $tag){
    						$tag_link = get_tag_link($tag->term_id);
    						$html .= "<a href=\"{$tag_link}\" title=\"{$tag->name} Tag\" class=\"tags\">";
    						$html .= "{$tag->name}</a>";

    On the first post, the tags is correct. But on the second post or more (I display two posts per page), the tags of first post is repeated with the tags of second posts.
    How can I fix this?
    Thanks so much!

  2. bcworkz
    Posted 2 years ago #

    Reset $html to an empty string before entering the foreach loop. This essentially discards th old tag data so you have a clean container for the next post.

  3. rafaht
    Posted 2 years ago #

    Oh! Thank you so much, my problem is resolved! :D

Topic Closed

This topic has been closed to new replies.

About this Topic