How To Remove Tag-Clouds Inline Style

  • Update On March 23rd, 2017
  • in WordPress
how to remove tag clouds inline style 800x247 - How To Remove Tag-Clouds Inline Style

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);
}
About This Author

My name is Parameshwar Roy (P. Roy), and I am a web developer. This is my personal blog to record my own thoughts. Though I am not a natural writer, I love to share my experiences. Hope my experiences will be useful to you...read more about me

2 Comments

You can post comments in this post.


  • That’s what I was looking for
    nice job

    Mouad 7 years ago Reply


  • Nice. your code is work, and how about to add for this tag clouds ??

    Cara Membuat Proposal 7 years ago Reply


Leave A Reply