This post was last updated on March 23rd, 2017 at 05:01 am
WordPress tags help us to sort content into more specific topics. Using Tag cloud widget we can display tags used on your site. However, tag cloud widget comes with some inline styling, for example, font-size
but according to SeoSiteCheckup, it is a good practice to move all the inline CSS rules into an external file for better for performance as well as to reduce bandwidth usage. In this article, I will show you how to remove tag cloud inline style more specifically removing the font-size inline style.
WordPress has a filter wp_generate_tag_cloud
that allows to edit the string input. You can use regex to find and remove the inline style:
//Remove Tag-Clouds inline style
add_filter('wp_generate_tag_cloud', 'remove_tagcloud_inline_style',10,1);
function remove_tagcloud_inline_style($input){
return preg_replace('/ style=("|\')(.*?)("|\')/','',$input);
//return preg_replace("/style='font-size:.+pt;'/", '', $input);
}
2 Comments
You can post comments in this post.
That’s what I was looking for
nice job
Mouad 7 years ago
Nice. your code is work, and how about to add for this tag clouds ??
Cara Membuat Proposal 6 years ago
Leave A Reply