W3 Total Cache
Manually rewrite css link? (3 posts)

  1. Qcybb
    Posted 2 years ago #

    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 :


    To this :


    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?


  2. amitbhatia
    Posted 2 years ago #

    Why don't you test it out and report back?

  3. Qcybb
    Posted 2 years ago #

    I did test it out - and it doesn't work.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • W3 Total Cache
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic