I am trying to load CSS and Javscripts through the functions. CSS are loading, but dont know what mistake has been done that javascripts and Jquery are not loading through the functions method.
I tried by directly loading scripts through the head section and it worked, but by functions method it is not loading. I am producing the excerpts of the code here →
/* Register scripts. */
wp_register_script( 'custom', JS . '/jquery-3.1.1.js');
wp_register_script( 'custom', JS . '/custom.js');
Do you think that there is any mistake commited in this also →
/*-------------------------------------------*/
/* 1. CONSTANTS */
/*-------------------------------------------*/
define( 'THEMEROOT', get_stylesheet_directory_uri() );
define( 'IMAGES', THEMEROOT . '/img' );
define( 'JS', THEMEROOT . '/js' );
The live WP site link can be found here for any direct troubleshooting.
Try to click the hamburger menu and then the scripts will not load thats why the hamburger menu is not animating.
The Complete Function →
if ( ! function_exists( 'klogeto_scripts' ) ) {
function klogeto_scripts() {
/* Register scripts. */
// wp_register_script( 'jquery', JS . '/jquery-3.1.1.js');
// wp_register_script( 'custom', JS . '/custom.js', array(), '20151215', true);
// wp_enqueue_script( 'custom' );
wp_register_script( 'custom-js', get_template_directory_uri() . 'js/custom.js', array(), '20151215', true );
wp_enqueue_script( 'custom-js' );
/* Load the stylesheets. */
wp_enqueue_style( 'style', THEMEROOT . '/css/style.css' );
wp_enqueue_style( 'responsive', THEMEROOT . '/css/responsive.css' );
wp_enqueue_style( 'fontawesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css' );
}
add_action('wp_enqueue_scripts','klogeto_scripts');
}