• Resolved fourwhitesocks

    (@fourwhitesocks)


    Having a hard time enqueueing a JavaScript file into my Ollie Child theme, tying to do it basically the same way I’ve been doing it for years and I cannot get it to work! This is in the Ollie Functions file…

    // add custom scripts  this breaks it
    
    function ollie_enqueue_scripts()
    {
    
    	wp_enqueue_script('custom-script', get_stylesheet_directory_uri() . '/js/custom-script.js', array(), false, true);
    	
    }
    
    add_action('wp_enqueue_scripts', 'ollie_enqueue_scripts', 999);

    I tried registering it first and that didn’t work either… has to be something dumb I’m missing! Any help would be great!

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter fourwhitesocks

    (@fourwhitesocks)

    To further clarify: the custom-script.js file is located in a JS folder that resides in the ollie-child theme directory, where is ollie-child is the active Ollie Child theme.

    ** the code above is in the functions.php file 🙂

    Thread Starter fourwhitesocks

    (@fourwhitesocks)

    SOLVED! Sorry for some reason I thought it had something to do w/ it being a Full site editing theme! I was missing a backslash and I added the __NAMESPACE__ 🙄🙄😶

    // add custom scripts and load last
    
    function ollie_enqueue_scripts()
    {
    
    	wp_enqueue_script('custom-script', get_stylesheet_directory_uri() . '/js/custom-script.js', array(), false, true);
    
    	//wp_enqueue_script('custom-script');
    }
    
    add_action('wp_enqueue_scripts', __NAMESPACE__ . '\ollie_enqueue_scripts', 999);
    
    Thread Starter fourwhitesocks

    (@fourwhitesocks)

    Marking as solved!

    Theme Author Mike McAlister

    (@mmcalister)

    Awesome, glad you got it sorted! 😎 Thanks for posting the fix for others!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Enqueueing custom javascript file in Ollie Child theme’ is closed to new replies.