Sunday, March 13, 2022

[FIXED] Wordpress/JavaScript troubles

Issue

I'm working on a Wordpress site and I want to use a sliding gallery that I wrote. I've been trying to enqueue it and I'm not having any luck getting it to work. When I look at the developer tools to see what sources are being pulled/if the console is throwing any errors, I'm not even seeing the JavaScript file show up.

file structure as shown on google dev tools for front-page.php (where the slider will exist) Screenshot of the file structure in the Google Developer tools Source tab

file structure as shown on google dev tools for all other pages enter image description here

functions.php code:

function glv_scripts() {
    wp_enqueue_style( 'glv-style', get_stylesheet_uri(), array(), _S_VERSION );
    wp_enqueue_script( 'script', get_template_directory_uri() . '/js/script.js', array(), null, true );
}
add_action( 'wp_enqueue_scripts', 'glv_scripts' );

Solution

I finally realized I was missing the footer call in front-page.php, so it wasn't showing up because I had it set to true for the footer but forgot the footer. :S



Answered By - monkeyduo

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.