Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Tsunamijaan/2c00eee2b13b17051afb60f8c2717874 to your computer and use it in GitHub Desktop.
Save Tsunamijaan/2c00eee2b13b17051afb60f8c2717874 to your computer and use it in GitHub Desktop.
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;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment