Sarmad Gardezi

Sarmad Gardezi

a freelance developer

How to Display Most Popular Tags in WordPress

D

o 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.

Leading Tags of Website

Do you have a bunch of “most searched” and “liked” tags on your WordPress site? If the answer is yes, you must be looking for something that can help you showcase the most popular tags of your website to your target audience, such as in a “tag cloud”. In this article, we will show you some easy to follow steps that can help you display your most popular tags on the site. However, before we start discussing the various methods of popular tag display, let’s review some basics about “Tags” in WordPress.

When and Why You Need to Display the Most Popular Tags on a WordPress site

Tags and categories are the two basic taxonomies that help you sort your website content in separate groups. For wider sections, sub-menus and topics on your site categories are preferable. However, tags help you to classify the content.

For the beginners, sometimes it becomes difficult to use tags and categories correctly, but there are many tools available online, which allows them to merge and even convert categories and tags according to their convenience.4

Getting Started

To deal with this issue, you can add the default tag cloud widget to your WordPress site, by navigating to Appearance >> Widgets page. Here, you can add the Tag cloud widget to your site’s sidebar.

The default tags widget can only show all of your site tags alphabetically. There is no way you can rearrange the sequence or limit the number of tags displayed on the site. You can resolve this issue by selecting the most often used or most popular tags on your WordPress site. This way you can help your users quickly understand what topics on your site are mostly discussed.

Using Plugin to Display Most Popular Tags

 

This is one of the most recommended methods to display your most popular tags easily. You need to install and activate the Simple Tags plugin.

Once the plugin in activated, go to the Appearance >> Widgets page and place the Tag Cloud or Simple Tags widget to your site’s sidebar.

After adding the widget to the sidebar, the widget space will expand and here you can make changes in the settings. You can select the tags that you would like to display in the configuration section. You can also make changes in the font size and colours as per your requirements.

To show your tags as per the popularity rate, select the count for “Order by for display tags” and make adjustments in descending in “Order for display tags” options.

Make sure you do not forget to click the “Save” button to store all your widget settings safely. Once it is done go to Your website Homepage & See the changes.

Display tags Manually in WordPress

Do add the code manually in your wordpress website  you need to add code in your WordPress website’s theme files. Before beginning, save a copy of your theme’s functions.php file prior to editing it, just in case.

Next, copy the below-mentioned code and add this to your WordPress Theme’s functions.php file.

function wpb_tag_cloud() {

$tags = get_tags();

$args = array(
'smallest' => 10,
'largest' => 22,
'unit' => 'px',
'number' => 10,
'format' => 'flat',
'separator' => " ",
'orderby' => 'count',
'order' => 'DESC',
'show_count' => 1,
'echo' => false
);

$tag_string = wp_generate_tag_cloud( $tags, $args );

return $tag_string;

}

// Add a shortcode so that we can use it in widgets, posts, and pages

add_shortcode('wpb_popular_tags', 'wpb_tag_cloud');

// Enable shortcode execution in text widget

add_filter ('widget_text', 'do_shortcode');

This code will automatically generate the top ten tags from your site in a cloud platform, with the number of posts associated with each tag. This will create a shortcode and enable the same in a text widget. Your shortcode will look like this:

[Wpb_popular_tags]

To display your most popular tags, enter the shortcode above exactly as it appears (including the square brackets) in any post, page or widget.

All Done, Now go the desire page & see the results.


RELATED POSTS

Video Tutorials