Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages »

HOWTO: Display tags with tag count on a post

Old Jun 27, 2013, 06:32 PM
Tim F
66 posts · Jul 2009
Hey all,
For a while I've been wanting to display the tags on a post only if there are more than 1 posts with that tag, and showing the total number of posts with that tag. The idea is to encourage site navigation by linking similar posts with tags, and not making people click on a tag only to find no other posts.
So the result would look like this:
View more posts tagged with: Elephants (3), Rabbits (1)

I have thrashed out the following code, which works. It is quite possibly not the most elegant solution so if you can improve it feel free I'm still using 3.5.1 so I just include this in Style & Edit Center Column > The Loop, underneath the post byline.
$tags = get_the_tags();
if (is_array($tags)) {
foreach ($tags as $tag) {
if($tag->count > 1) $tagstart = 'Read more posts tagged with:  ';
$tag_link = get_tag_link( $tag->term_id );
if($tag->count > 1) $tagstring .= "<a href='{$tag_link}'>" . $tag->name . ' (' . $tag->count . ')' . "</a>" . ', '
$tagdisp = $tagstart . $tagstring;
echo rtrim($tagdisp, ', ');


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting number of post count in category page tropmixxer Page & Category Menu Bars 2 Apr 25, 2011 07:55 AM
Comment count next to post title? crashley1784 Comments, trackbacks & pings 0 Jun 28, 2010 06:22 PM
[SOLVED] Display 'Post Count' on all MULTI post pages joan Post-Kicker, -Byline & -Footer 1 Nov 18, 2009 03:08 AM

All times are GMT -6. The time now is 08:47 AM.

Powered by vBulletin® Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.