Site logo

[Resolved] Exclude tags from tag cloud blog on GP sidebar element

Home Forums Support [Resolved] Exclude tags from tag cloud blog on GP sidebar element

Home Forums Support Exclude tags from tag cloud blog on GP sidebar element

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2319418
    George

    I am using this code in an attempt to exclude certain tags from a tag cloud widget block that I have on my GP sidebar element:

    add_filter( 'widget_tag_cloud_args', 'gm_exclude_tag_from_tag_cloud');
    function gm_exclude_tag_from_tag_cloud( $args ) {
      $args[ 'exclude' ] = '46,42,48,43,49,47,50';
      return $args;
    }

    It doesn’t seem to work. I suspect it’s because I use a tag cloud block and not an actual WordPress widget. Is there a solution?

    #2319788
    David
    Staff
    Customer Support

    Hi George,

    i assume they would use the wp_tag_cloud function in the Block.
    And that has a filter hook:

    https://developer.wordpress.org/reference/hooks/wp_tag_cloud/

    And you can see its Args here:

    https://developer.wordpress.org/reference/functions/wp_tag_cloud/

    So simply swapping the hook name may work:

    add_filter( 'wp_tag_cloud', 'gm_exclude_tag_from_tag_cloud');
    function gm_exclude_tag_from_tag_cloud( $args ) {
      $args[ 'exclude' ] = '46,42,48,43,49,47,50';
      return $args;
    }
    #2319887
    George

    Thanks, David.

    It’s so weird, it only removes one tag beginner and shows this message at the top:
    4a href="SITEURL/tag/beginner/" class="tag-cloud-link tag-link-42 tag-link-position-1" style="font-size: 10pt;" aria-label="beginner (3 items)">beginner

    I’ve attached a URL.

    #2319954
    David
    Staff
    Customer Support

    Found this:

    https://github.com/WordPress/gutenberg/issues/33990

    No fix as yet. Might want to resort to a classic widget or use a shortcode

    #2320073
    George

    Awesome, shortcode works, thanks David!

    #2320081
    David
    Staff
    Customer Support

    Glad to hear that 🙂

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