How to show Show all tags sorting by the number of post

Shortlink:

Hi, Today i will teach you How to show 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;
?>

 

Thanks for read this article, you can share this post if you think this helpfully post.

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!




%d bloggers like this: