WordPress.org

Support

Support » Plugins and Hacks » [Resolved] How to enque scripts only on certain pages

[Resolved] How to enque scripts only on certain pages

  • Hello! I use wp_enque_script to add several scripts to the page header. I would like to be able to add them only on certain pages, like the home page. The problem is that conditional tags such as is_home() don’t seem to work.

    This is how I’m currently including the scripts:

    add_action('init', 'js_loader');
    
    function js_loader(){
       wp_enque_script('script_name', 'script_src', array('dependencies'));
    }

    Conditional tags added inside js_loader() or wrapped around add_action() do not seem to work.

    Any ideas?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] How to enque scripts only on certain pages’ is closed to new replies.