[Resolved] Tag cloud font size not working

Home Forums Support [Resolved] Tag cloud font size not working

Home Forums Support Tag cloud font size not working

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2051620
    Rachel

    I’m using the built-in Tag Cloud block/function, and I want the font sizes to vary based on the number of posts with that tag.

    I tried simply setting the font size with CSS, but it makes all the terms the same size.

    I tried (using the Tag Cloud block inside of a GP Block-Hook Element) adding the filter hook code below (using the Code Snippets plugin), and it works for the largest size, but does not affect the smallest size.

    add_filter('widget_tag_cloud_args','set_tag_cloud_sizes');
    function set_tag_cloud_sizes($args) {
      $args = array(
        'smallest'	=> 1, 
        'largest'	=> 2, 
        'unit'	=> 'em'
      );
      return $args;
    }

    I have tried using a Hook Element with the code below, and I end up with half of the code displaying on the front end.

    <?php 
    $tags = get_terms('post_tags')
    $args = array(
      'smallest'	=> 1,
      'largest'	=> 2,
      'unit'	=> 'em',
      'number'	=> 0
    ); 
    wp_generate_tag_cloud( $tags, $args );
    ?>

    I even tried setting the sizes with ‘px’ and ‘pt’ instead of ’em’ with no success.

    Any advice on how I can properly set the tag cloud font sizes?

    #2051664
    Elvin
    Staff
    Customer Support

    Hi Rachel,

    Can you let us have a look at the page w/ the tag cloud? To inspect it and have a clearer idea if something’s overriding the sizes.

    #2052346
    Rachel

    Hey Elvin, I put the link in the private info – its a work in progress πŸ™‚

    #2052379
    Leo
    Staff
    Customer Support

    Hmm I don’t believe this is a theme issue but let’s test.

    Does the tag cloud block and code works if you add it in a page/post content instead of a block element?

    If not does the method work in a Twenty series WP theme environment?

    Let me know πŸ™‚

    #2052493
    Rachel

    Hi Leo,

    I tried the Tag Cloud in regular content of a page, and with the Twenty Twenty theme, and it still didn’t work.

    So that means this is an issue with the Tag Cloud block itself, not something to do with GeneratePress?

    #2052603
    Leo
    Staff
    Customer Support

    Yeah that means this filter widget_tag_cloud_args isn’t actually working.

    You can check with WordPress’ support team and see if they are able to comment πŸ™‚

    #2052735
    Rachel

    Thank you for your help Leo!

    I did some more googling, and I found other complaints about that filter not working, but no alternatives or solutions.

    Finally came across this hack-y solution using the inline style for the CSS selector:

    .tag-cloud-link[style*=": 8"] { font-size: 1em !important; }
    

    Thought I’d post it just in case someone comes across this question in the future!

    #2054791
    Leo
    Staff
    Customer Support

    Thanks for sharing!

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.