WordPress Shortcodes – Optional Styles

The general process for this is:

  1. Create a function, hooked into wp_enqueue_scripts
  2. Inside your function, cycle through the Loop, looking for your shortcode string
  3. If found, call wp_enqueue_style( 'my_custom_style' )
  4. Rewind the Loop, by calling <?php rewind_posts(); ?>