you can do so using this code snippet;
add_filter('autoptimize_filter_css_replacetag','kduadmn_css_replacetag',10,1);
function kduadmn_css_replacetag($replacetag) {
return array("</head>","before");
}
hope this helps,
frank
Is it not possible to inject the css right after the yoast meta tags?
well, AO doesn’t know what Yoast’s meta tags are, but you can change the code snippet according to your needs 🙂
some explanations;
-> the first argument is an HTML tag (which needs to be present, obviously, which is why by default AO uses <title> and the example uses </head>).
-> the 2nd argument is either before or after, indicating if the CSS has to come before of after the tag.
-> the 2nd variable can also be replace, in which case you would add something (e.g. <!--ao-css-replacetag-->) to the head (in your theme) and then use that tag as first argument and replace as the 2nd one.
Thanks for the quick reply.
Ok, I want to use the replace variable but don’t know how to insert <!–ao-css-replacetag–> at the desired location within <head></head> because all the codes and tags by plugins are inserted automatically within the <head></head> section using wp_head.
in that case you’ll have to find a tag in your sites head which always occurs and use after/ before?
Ok @optimizingmatters, thank you for the valuable help and explanations, I really appreciate your knowledge and plugin support.
Best regards!