Is there a nice way to remove the inline style from wordpress tag cloud tags? I'd like to set the same size for all tags and do not want inline styles at all if I can help it.
Thanks
Is there a nice way to remove the inline style from wordpress tag cloud tags? I'd like to set the same size for all tags and do not want inline styles at all if I can help it.
Thanks
You can use WordPress' core filters to modify output by different functions. wp_generate_tag_cloud()
has a filter that allows you to edit the string input. Below is a function that regexs the string, finds the inline style and removes it.
add_filter('wp_generate_tag_cloud', 'xf_tag_cloud',10,3);
function xf_tag_cloud($tag_string){
return preg_replace("/style='font-size:.+pt;'/", '', $tag_string);
}
Unfortunately Rezens regexp didn't work in my case. You can use the following filter and regexp to remove the whole inline style tag on the output:
add_filter('wp_generate_tag_cloud', 'myprefix_tag_cloud',10,1);
function myprefix_tag_cloud($tag_string){
return preg_replace('/style=("|\')(.*?)("|\')/','',$tag_string);
}
If you inserting this with PHP, it doesn't help with removing the inline styles but you can set the 'smallest' and 'largest' parameters to ensure the font size is the same, see the Codex for more info on this.
If you don't want to change your theme's code you can add a css font-size rule adding !important
, it should override inline style.
© 2022 - 2024 — McMap. All rights reserved.