WordPress Shortcode and Dynamic CSS

The closest to a reference technique in core would be shortcode.

If you look at the source of implementing gallery_shortcode() function you’ll see that it:

  1. Generates instance number (so multiple shortcodes can be distinguished).
  2. Outputs dynamic CSS inline into a page source, for each instance.

I wouldn’t consider it particularly neat solution, but it is about as close as it gets within constraints of WP shortcodes architecture.

Leave a Comment