Support » Plugins » Add script and css to header from withing shortcode

  • Hi,
    Trying to write a plugin. Would like to use wp_enqueue_script and wp_enqueue_style on init from within my plugins shortcode.
    Is there a way to add css and javascript to page header from within a shortcode?

    Anything pointing me in right direction is highly appreciated!

    Thanks!
    Quokka

Viewing 1 replies (of 1 total)
  • Hi,
    in the case of javascript it will be a better solution to load it in the footer. And based in a shortcode you will not be able to load anything in the header because the page will be processed in the following order:
    1.header
    2.body(here will be the shortcode)
    3.footer
    So you when you will trigger the action by shortcode, the header it will be already processed.
    If you are interested study this page : http://scribu.net/wordpress/optimal-script-loading.html and you can check out my plugin based on that page. The plugin name is: activator.
    About CSS cant tell you much, currently I do some studies about it.
    best regards
    cjoseph

Viewing 1 replies (of 1 total)
  • The topic ‘Add script and css to header from withing shortcode’ is closed to new replies.