Sysadmins of the North
Don't forget to share this post!

Change WordPress stylesheet_uri with add_filter()

How to change WordPress’ stylesheet URL with add_filter(). Just a quicky: To change the stylesheet URL in WordPress, to offload static content, put the following in your theme’s functions.php file:


add_filter('stylesheet_uri', 'saotn_change_css');
function saotn_change_css() {
  return "//css.example.com/wp-content/themes/[theme name]/style.css";
}

Now your theme’s style.css will be loaded from a sub domain -or hostheader- called css.example.com. This can improve overall website performance.

About the Author Jan Reilink

My name is Jan. I am not a hacker, coder, developer, programmer or guru. I am merely a system administrator, doing my daily thing at Vevida in the Netherlands. With over 15 years of experience, my specialties include Windows Server, IIS, Linux (CentOS, Debian), security, PHP, WordPress, websites & optimization. Want to support me and donate? Use this link: https://paypal.me/jreilink.

follow me on:

Leave a Comment:

Skip to content