How to Display Most Popular Tags in WordPress

آذر ۲۶, ۱۳۹۶

Do you want to display the most popular tags used on your WordPress site? Tags and categories are the two default ways to sort your content in WordPress. Categories often get more exposure due to their broader scope, which gives tags a little less attention. In this article, we will show you how to easily display your most popular tags in WordPress.

Why and When You Should Display Most Popular Tags in WordPress

Categories and tags are the two default taxonomies to sort your articles in WordPress. Categories are used for broader topics or sections on your website while tags are well-suited to specific ideas within the context of your articles.

Often beginners end up using them incorrectly, but there are easy tools which allow you to merge categories and tags and even convert them.

Once you start using categories and tags correctly, you’ll likely have more tags on your website than categories. Due to their broader scope, you can put categories in navigation menus, but your tags may often remain less explored.

One way to deal with this is by adding the default tag cloud widget by going to the Appearance » Widgets page, and add Tag Cloud widget to a sidebar.

However, you will notice that the default tags widget will show all your tags alphabetically. You cannot rearrange their order or limit the number of tags to be displayed.

You can solve this, by displaying the most popular or most often used tags on your WordPress site.

This will allow your users to quickly get an idea on what topics are more frequently discussed on your site. It will also help them discover more content, which means more page views and user engagement.

Now let’s take a look at how to easily display your most popular tags in WordPress.

Video Tutorial

Subscribe to WPBeginner

If you don’t like the video or need more instructions, then continue reading.

  1. Display Most Popular Tags in WordPress Using Plugin
  2. This method is easier and recommended for most users.
  3. First thing you need to do is install and activate the Simple Tags plugin. For more details, see our step by step guide on how to install a WordPress plugin.
  4. Upon activation, you need to visit Appearance » Widgets page and add ‘Tag Cloud (Simple Tags)’ widget to the sidebar.
  5. The widget will expand, and you will be able to see its settings.
  6. Here you can select the number of tags you want to display, font sizes, colors, etc.
  7. To display your tags by popularity, make sure you select count for ‘Order by for display tags’ and descending for ‘Order for display tags’ options.
  8. Don’t forget to click on the save button to store your widget settings.
  9. You can now visit your website to see your popular tags in action.
  10. Display Popular Tags in WordPress Manually
  11. This method requires you to add code in your WordPress theme files. If you haven’t done this before, then please see our guide on how to copy and paste code in WordPress.
  12. First, you need to add this code to your theme’s functions.php file or a site-specific plugin.
  13. ۱
  14. ۲
  15. ۳
  16. ۴
  17. ۵
  18. ۶
  19. ۷
  20. ۸
  21. ۹
  22. ۱۰
  23. ۱۱
  24. ۱۲
  25. ۱۳
  26. ۱۴
  27. ۱۵
  28. ۱۶
  29. ۱۷
  30. ۱۸
  31. ۱۹
  32. ۲۰
  33. ۲۱
  34. ۲۲
  35. ۲۳
  36. ۲۴
  37. ۲۵
  38. function wpb_tag_cloud() {
  39. $tags = get_tags();
  40. $args = array(
  41.      smallest                   => 10,
  42.      largest                    => 22,
  43.      unit                       =>  px ,
  44.      number                     => 10,
  45.      format                     =>  flat ,
  46.      separator                  =>    ,
  47.      orderby                    =>  count ,
  48.      order                      =>  DESC ,
  49.      show_count                 => 1,
  50.      echo                       => false
  51. );
  52.  $tag_string = wp_generate_tag_cloud( $tags, $args );
  53.  return $tag_string;
  54.  }
  55. // Add a shortcode so that we can use it in widgets, posts, and pages
  56. add_shortcode( wpb_popular_tags ,  wpb_tag_cloud );
  57.  // Enable shortcode execution in text widget
  58. add_filter ( widget_text ,  do_shortcode );
  59. This code simply generates the top 10 tags from your website in a cloud with number of posts in each tag. After that it creates a shortcode wpb_popular_tags and enables shortcode in text widget.
  60. You can now add shortcode [wpb_popular_tags] in any post, page, or widget to display your most popular tags.
  61. Want to style your tags differently? Check out our guide on how to style tags in WordPress for detailed instructions and example.
  62. We hope this article helped you learn how to display most popular tags in WordPress. You may also want to see our list of most wanted WordPress tips, tricks, and hacks for beginners.
  63. If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.