Show post tags on loop

Posted in: Newsmag
Post count: 26

Hello,
I am trying to show tags in the post loop, not in the single post.
I’ve tried WP native function:
get_the_tags();
echo get_the_tag_list();
and the theme function:
get_the_tags();
They do not work. I must have missed something 🙂
Please advise.

Post count: 1291

Hi,

Edit each module and add the following code: – http://screencast.com/t/9C3OBjKp

function get_the_tags() {

        $buffy = '';

        $td_post_tags = get_the_tags();
        if ($td_post_tags) {
            $buffy .= '<ul class="td-tags td-post-small-box clearfix">';
            $buffy .= '<li><span>' . __td('TAGS') . '</span></li>';
            foreach ($td_post_tags as $tag) {
                $buffy .=  '<li><a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a></li>';
            }
            $buffy .= '</ul>';
        }

        return $buffy;
    }

and

<?php echo $this->get_the_tags();?>

Result – http://screencast.com/t/LXiSfg6TQh

Thank you, Emil G.

  • This reply was modified 11 years by Emil G.
Post count: 26

Thanks for you help. Well, that was exactly what I did. That’s why I said “I must have missed something”.
Of course, I did it again and followed your steps and code EXACTLY, still no tags shown. Weird.

Post count: 7909

Hi,

I also tested this and Emil’s code works:
Module 1: http://screencast.com/t/cjqP4GFpZg
Module 5: http://screencast.com/t/9BNKc6Qx9

Please make sure that you have tags on post.

Thanks!

Post count: 26

I tested it again this morning. It works in the loops of taxonomy, search, archive, etc… but not on Visual Composer’s pages. Mmm…

  • This reply was modified 11 years by handiso.
Post count: 1291

Hi,

Replace the code with this one:

    function get_the_tags($post_id) {

        $buffy = '';

        $td_post_tags = get_the_tags($post_id);
        if ($td_post_tags) {
            $buffy .= '<ul class="td-tags td-post-small-box clearfix">';
            $buffy .= '<li><span>' . __td('TAGS') . '</span></li>';
            foreach ($td_post_tags as $tag) {
                $buffy .=  '<li><a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a></li>';
            }
            $buffy .= '</ul>';
        }

        return $buffy;
    }

and this:

<?php echo $this->get_the_tags($this->post->ID);?>

Thank you, Emil G.

  • This reply was modified 11 years by Emil G.
Post count: 26

Great! Thank you very much for your help.
I changed it a little bit.
Add the following code to: themedir “\includes\wp_booster\td_module.php” instead of each module.


function get_the_tags() {
	$buffy = '';
	$td_post_tags = get_the_tags($this->post->ID);
	if ($td_post_tags) {
		$buffy .= '<ul class="td-tags td-post-small-box clearfix">';
		$buffy .= '<li><span>' . __td('TAGS') . '</span></li>';
		foreach ($td_post_tags as $tag) {
			$buffy .=  '<li><a>term_id) . '">' . $tag->name . '</a></li>';
		}
		$buffy .= '</ul>';
	}
	return $buffy;
}

and add this to module files:
<?php echo $this->get_the_tags();?>

  • This reply was modified 11 years by handiso.
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic.