Add inline style to pages where shortcode was used
In this case, has_shortcode() is your friend. First, we hook into wp_print_styles, instead of wp_head. In the func we hook we check if the post contains our shortcode. If it does, we get the CSS we want and output it as an inlined <style>. add_action (‘wp_print_styles’, ‘wpse_enqueue_shortcode_css’) ; function wpse_enqueue_shortcode_css () { global $post ; … Read more