In a WordPress theme I have a custom function that generates some HTML and CSS based on factors on the page. Previously I had simply dumped the generated CSS into embedded <style> tags. However, as this is breaking W3C validation, I'd like to find a way to maintain the flexibility of calling the function in the theme files (page.php, single.php, etc.), but have the generated CSS be outputted in the <HEAD> tag.
I understand wp_add_inline_style() can enqueue inline styles, but I'm unable to see how this could work in my above described situation. Any help is much appreciated.
wp_head()hook?