Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Frank Goossens

    (@futtta)

    In 1.8.x this is fixed, but in the upcoming 1.9 the API allows one to change the place the CSS (and JS) is inserted. Example code (to be added to e.g. your theme’s functions.php);

    add_filter('autoptimize_filter_css_replacetag','my_ao_override_css_replacetag',10,1);
    function my_ao_override_css_replacetag($replacetag) {
    	return array("<head>","after");
    	}

    with the first element of the array identifying the tag to use for replacement and the second argument whether that the injected CSS should be “before”, “after” or “replace” that tag.

    hope this helps,
    frank

    Thread Starter a_usman

    (@a_usman)

    I tried this example code, but nothing happened. I added it in functions.php.

    Do I need to add something in the header.php too??

    PS: The above example code is for 1.9 or 1.8??

    Plugin Author Frank Goossens

    (@futtta)

    Hmmm, are you sure you’re already on the not-yet-released Autoptimize 1.9.0?

    Thread Starter a_usman

    (@a_usman)

    I just installed 1.9 and the example code is working now.

    But I don’t see any way to add the css after yoast’s plugin. I explored and found only two tags for this purpose, <head> and </title> but they are still above yoast’s tags.

    Plugin Author Frank Goossens

    (@futtta)

    you could inject before </head>, no?

    Thread Starter a_usman

    (@a_usman)

    Thanks Frank. I wonder why didn’t I think about it before.

    Now working good.

    Plugin Author Frank Goossens

    (@futtta)

    happy happy joy joy! ??

    have a nice weekend!
    frank

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Can I change the location of CSS output??’ is closed to new replies.