Change wordpress tag cloud setting

You can install a plugin to change the standard tagcloud to your liking, or you can hack the wordpress core file to do this, but let's do it the right way. As for almost everything in wordpress there is a filter for this. So we simply have to create a function and add the filter. Within the function we can set our arguments (the options we'd like to change). In my case I wanted to have the same fontsize no matter how many posts there are with that tag name. This is what I did:

1
2
3
4
56
7
8
9
1011
function widget_custom_tag_cloud($args) {
 
    $args = array(
                'unit'      => 'px',
                'largest'   => 12,                'smallest'  => 12,
        );
 
    return $args;
}add_filter( 'widget_tag_cloud_args', 'widget_custom_tag_cloud' );

Simple put this in your functions.php and you're done. You change many things, for example you can exclude certain tags or change the order. For all the possible arguments check the wordpress codex on this matter.

  • I apologize for my poor English. I should have paid more attention in school...
    If there are any huge mistakes please inform me
  • I've never studied C, Javascript or PHP. Everything I know is learned via youtube and google.
    I realize my code is often unnecessarily long, but I prefer writing it this way so I can still understand myself later on. If there are other mistakes please let me know.