List Tags Ordered By Post Count in WordPress Tag Cloud Widget – WordPress Tutorial

By | September 19, 2019

We can add a tag cloud widget for our wordpress website, however, tags displayed in wordpress tag cloud widget are not ordered by their post counts. In this tutorial, we will implement to display and order tags in tag cloud widget with their post counts.

wordpress tag cloud widget

Open your theme functions.php

Add code below in functions.php

function set_widget_tag_cloud_args($args) {
  $my_args = array('orderby'=>'count', 'order'=>'DESC' );
  $args = wp_parse_args( $args, $my_args );
return $args;
}
add_filter('widget_tag_cloud_args','set_widget_tag_cloud_args');

Save file, then you will find tags in tag cloud widget are displayed by their counts, from big to small.

List Tags Ordered By Post Count in WordPress Tag Cloud

Leave a Reply

Your email address will not be published. Required fields are marked *