Archived topic
Exclude tags from tag cloud blog on GP sidebar element
5 replies · Started by George on August 21, 2022
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?
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;
}
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.
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
Awesome, shortcode works, thanks David!
Glad to hear that :)