0

Each post has 5 tags. But I want to display only 1 tag and every time it must be a random tag.

Can you please tell me how I can do it?

0

Someone already asked this question and can be found here: [https://stackoverflow.com/questions/17321603/how-to-display-a-list-of-random-tags-in-wordpress/22323541]Duplicate issue is resolved[1]

2
  • It's a list of all tags (tag cloud), but I need to display 1 random pot tag in the post. – Seryozha Mar 31 at 9:02
  • function jr_get_tags_but_exclude() { $alltags = get_tags( $args ); shuffle($alltags); $count=0; if ($alltags) { foreach($alltags as $tag) { $count++; echo '<a href="'.get_tag_link($tag->term_id).'">'.$tag->name.'</a>'; if( $count >0 ) break; } } } – PVee Marketing Mar 31 at 16:50

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.