• I am converting an HTML page to a WordPress theme for a customer, and everything was going fine until I got to the JavaScript part.

    I can get the css files to work just fine by using

       wp_register_style('header', get_template_directory_uri() . '/css/header.css', array(), 1, 'all');
        wp_enqueue_style('header');

    I have tried to add the JS files, but for some reason they are not registered when I test the page. What have I missed?

    function shapeSpace_include_custom_jquery() {
    
    	wp_deregister_script('jquery');
    	wp_enqueue_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js', array(), null, true);
    
    }
    add_action('wp_enqueue_scripts', 'shapeSpace_include_custom_jquery');
    
    function load_javascript() {
        
        wp_register_script('script2', get_template_directory_uri() . '/js/script2.js', array(), 1, 1, 1);
        wp_enqueue_script('script2');
        wp_register_script('script3', get_template_directory_uri() . '/js/script3.js', array(), 1, 1, 1);
        wp_enqueue_script('script3');
        wp_register_script('navigation', get_template_directory_uri() . '/js/navigation_script.js', array(), 1, 1, 1);
        wp_enqueue_script('navigation');
        wp_register_script('scroll', get_template_directory_uri() . '/js/scroll.js', array(), 1, 1, 1);
        wp_enqueue_script('scroll');
    
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • It looks like you’re not calling the load_javascript() function anywhere, only the shapeSpace_include_custom_jquery() function. You will need to call both if you want both to work.

    Hello,

    Please add code.
    add_action('wp_enqueue_scripts', 'load_javascript');

    Please check and let me know if any

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘JavaScript files are not registered’ is closed to new replies.