Show empty tags in a tag cloud in WordPress using add_filter

If you are using tags for tagging custom types or fields in WordPress, the core of WordPress will not know about it. That’s why when showing tag cloud widget in a sidebar, it will list only those used in posts. All the other ones are treated as empty tags (unused tags) and they won’t be displayed.

But adding this short code into your theme’s functions.php file will make sure that all tags are listed:


function showemptytags($args) {
return $args;

Using filters you are changing the default value of the query used for displaying the tags. This code forces the query to include also the empty or unused tags in your tag cloud.

Have a comment? Join discussion on Mastodon as a reply to: