Ready to get started?Download WordPress


[resolved] Problems with tags display (3 posts)

  1. rafaht
    Posted 10 months 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 10 months 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 10 months ago #

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


You must log in to post.

About this Topic