Roots Rewrites will rewrite your static theme and plugin assets:
/wp-content/themes/themename/assets/css/ to /assets/css/
/wp-content/themes/themename/assets/js/ to /assets/js/
/wp-content/themes/themename/assets/img/ to /assets/img/
/wp-content/plugins/ to /plugins/
Note: If you use Composer to manage WordPress then you don't need to use this plugin, as your paths would look like:
/app/themes/themename/assets/css/
/app/themes/themename/assets/js/
/app/themes/themename/assets/img/
/app/plugins/
- Roots Theme (6.5.1+)
It is recommended to install this plugin prior to installing your Roots theme as the roots_rewrites()
plugin function is only called on the after_setup_theme
action. If this plugin is installed after the theme, you may have to update your permalink settings to force the .htaccess writes.
If you're using Nginx, you'll need to add the Roots rewrites to your server config before the PHP block (location ~ \.php$
):
location ~ ^/assets/(img|js|css|fonts)/(.*)$ {
try_files $uri $uri/ /wp-content/themes/roots/assets/$1/$2;
}
location ~ ^/plugins/(.*)$ {
try_files $uri $uri/ /wp-content/plugins/$1;
}
Use the Roots Discourse to ask questions and get support.
- Removed from Roots Theme, moved to plugin
MIT License