How do I load several JavaScripts for a specific page?
-
I’m currently using this code:
function enqueue_myscript() { wp_enqueue_script('jquery-javascript', true ); wp_enqueue_script('javascript', true); wp_enqueue_script('ijavas', get_template_directory_uri() . '/js/', array( 'jquery' ), '', true ); wp_enqueue_script('javas2', get_template_directory_uri() . '/js/', array( 'jquery' ), '', true ); } if(is_page('index.php')){ add_action('wp_enqueue_scripts', 'enqueue_myscript'); }I can’t seem get this to work. I know it’s not index.php, so how can I point it accordingly to only the index page? I am not using a template page either.
The script is being called for every single page, but only the index.php contains the required code that uses the script.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘How do I load several JavaScripts for a specific page?’ is closed to new replies.