Always show same size tags for Tag Cloud in WordPress Admin

I wanted to know if there was a way to modify the back-end of WordPress to do 2 things:

  • Make all tags’ font the same size, so none are larger than the others
  • Always show the most used tags when creating/editing a post

This only applies to the back-end of WordPress, not calling the tag cloud or any sort of front-end CSS that would be found in the theme.

Related posts

3 comments

  1. use this at functions.php

        /* Tagcloud, change the font size */
    function custom_tag_cloud_widget($args) {
        $args['largest'] = 13; //largest tag
        $args['smallest'] = 13; //smallest tag
        $args['unit'] = 'px'; //tag font unit
        return $args;
    }
    add_filter( 'widget_tag_cloud_args', 'custom_tag_cloud_widget' );
    
  2. I think I have a simpler solution:

    Install the plugin Add Admin CSS

    Go to Settings and put this code:

    p#tagcloud-post_tag.the-tagcloud a {
      font-size: 1em!important; 
    }
    

    I put 1em but feel free to put whatever value you prefer.

  3. With wp_tag_cloud you can set the smallest and largest argument to the same value:

    $args = array(
        'smallest'                  => 8, 
        'largest'                   => 8,
    );
    echo wp_tag_cloud($args);
    

    Unfortunately, that would require hacking the Core. Also, unfortunately, I don’t see a filter that will allow you to alter those argument directly, so you are going to have to do this a bit brute-force-y.

    add_action(
      'load-edit-tags.php',
      function () {
        add_filter(
          'wp_generate_tag_cloud',
          function ($return) {
            $pat = '|font-size: [0-9]+([^;]+)|';
            return preg_replace($pat,'8$1',$return);
          },
          1,2
        );
      }
    );
    

    Hooking to load-edit-tags.php should cause this to operate only on the wp-admin/edit-tags.php page on the backend, which is what I assume you want.
    Reference: http://codex.wordpress.org/Function_Reference/wp_tag_cloud

Comments are closed.