Manually rewrite css link?
-
When the option “Rewrite URL structure” is enabled in the “Minify” tab, for some reason the plugin refuses to create the .css file.
However with that option disabled, it saves the minified file without issues.
What I would like to do is keep the option disabled – but rewrite the .css file link (in the header) myself. That way the plugin keeps working and I am able to use my CDN for the css file.
What I have tried is :
function change_stylesheet_loc($uri) { $uri = str_replace('example.com', 'cdn.example.com', $uri); $uri = str_replace('index.php?file=', '', $uri); return $uri; } add_filter('stylesheet_uri', 'change_stylesheet_loc', 20000);
The code above should have change this :
https://example.com/wp-content/w3tc/min/index.php?file=6fb9f/default.include.c95d49.css
To this :
https://example.com/wp-content/w3tc/min/6fb9f/default.include.c95d49.css
Do I need to use a different filter hook than “stylesheet_uri”? Does W3 Total Cache have it’s own filter hook I can use?
- The topic ‘Manually rewrite css link?’ is closed to new replies.