Show all tags sorting by the number of post

<?php
$tags = get_terms( array("post_tag"), array("orderby"=>"count","order"=>"DESC"));
if ( !empty( $tags ) && !is_wp_error( $tags ) ) :
echo '<ul>';
foreach ( $tags as $tag ) :
echo '<li>' . $tag->name . '(' . $tag->count . ')</li>';
endforeach;
echo '</ul>';
endif;
?>

Leave a Reply

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