1

I need to get post popular tags. Here what I found from https://codex.wordpress.org/Function_Reference/wp_tag_cloud

$tag = wp_tag_cloud( 'smallest=8&largest=22&number=2&orderby=count&format=array' );

Here is an example from Wordpress site:

Cloud displayed under Popular Tags title

<?php if ( function_exists( 'wp_tag_cloud' ) ) : ?>    
<h2>Popular Tags</h2>
<ul>
<li><?php wp_tag_cloud( 'smallest=8&largest=22' ); ?></li>
</ul>    
<?php endif; ?>

I did not understand this parameters meaning smallest=8&largest=22 and does this example what I need?

3
  • 2
    smallest and largest are maximum font size that a tag can have based on it's popularity (usage). The largest tag in output on website means most popular tag. And yes, it will work. Use it and you will know. – Robert hue Oct 6 '15 at 6:03
  • How you want to determine the popularity of posts? I have two suggestions here: either you can consider post comment count or the number of views as a criteria. Then you can fire a query to get tags of posts having more comments or views. – Prasad Nevase Oct 6 '15 at 6:20
  • @ItsMePN I think he is asking about popular post tags not popular posts. – Robert hue Oct 6 '15 at 6:59
1

It is the max and min font size for most popular and least popular tags. If you are just want to display the popular tags and not the cloud then you can use the format option to display as an unordered list.

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.