0

I'm using wp_enqueue rather than including in the footer directly. I found that the path for the js files is correct (checked via page source).

NOT WORKING

wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/vendor/jquery.js', array (), NULL, true);

wp_enqueue_script( 'input', get_template_directory_uri() . '/js/vendor/what-input.js', array ('jquery'), NULL, true);

wp_enqueue_script( 'foundation-core', get_template_directory_uri() . '/js/vendor/foundation.js', array ('jquery'), NULL, true);

wp_enqueue_script( 'ext', get_template_directory_uri() . '/js/app.js', array ('jquery'), NULL, true);

WORKING

<script src="<?php bloginfo('template_directory'); ?>/js/vendor/jquery.js"></script>  
<script src="<?php bloginfo('template_directory'); ?>/js/vendor/what-input.js"></script>
<script src="<?php bloginfo('template_directory'); ?>/js/vendor/foundation.js"></script>
<script src="<?php bloginfo('template_directory'); ?>/js/app.js"></script>
3

2 Answers 2

1

In Wordpress to enqueue style and Css you wp_enqueue_script method. That you wrote fine but you have to run these function at the time when WordPress enqueue scripts. i.e you have to call these function at wp_enqueue_scripts action. wp_enqueue_scripts this action will call when WordPress load scripts. so your code will look like

add_action( 'wp_enqueue_scripts', 'load_my_site_scripts' );
function load_my_site_scripts(){
    wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/vendor/jquery.js', array (), NULL, true);
    wp_enqueue_script( 'input', get_template_directory_uri() . '/js/vendor/what-input.js', array ('jquery'), NULL, true);
    wp_enqueue_script( 'foundation-core', get_template_directory_uri() . '/js/vendor/foundation.js', array ('jquery'), NULL, true);
    wp_enqueue_script( 'ext', get_template_directory_uri() . '/js/app.js', array ('jquery'), NULL, true);
}

Add this code in your theme functions.php

Sign up to request clarification or add additional context in comments.

1 Comment

Yes you need to add this into this action only.
0

Try with creating function

function load_css_js() {
wp_enqueue_style( 'gdgt-base', get_template_directory_uri() . '/css/gdgt-base.css', false, NULL, 'all' );
wp_enqueue_style( 'gdgt-icon', get_template_directory_uri() . '/icons/css/gdgt.css', false, NULL, 'all' );

wp_register_script( 'gdgt-base', get_template_directory_uri() . '/js/gdgt-base.js', array( 'jquery' ), NULL, false );
wp_enqueue_script( 'gdgt-base' );
}

add_action( 'wp_enqueue_scripts', 'load_css_js' );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.