Jump to content
Search Community

Enqueue GSAP into WordPress theme

jerryB test
Moderator Tag

Recommended Posts

Hi,

I downloaded the member source files and have them in my theme's directory; I'm trying to enqueue to GSAP and ScrollTrigger, but not sure of the exact coding or which files in the folder I need to connect to; this is what I have, but it's not working ... thanks

<?php
function add_gsap_scripts() {

    wp_enqueue_script ( 'gsap-js' , get_stylesheet_directory_uri() . '/lib/gsap/minified/gsap.min.js', array( 'jquery' ), '1', true );
    wp_enqueue_style ( 'gsap-ScrollTrigger' , get_stylesheet_directory_uri() . '/lib/gsap/minified/ScrollTrigger.min.js', '', '1', 'all' );

    wp_enqueue_script( 'gsap-custom', get_template_directory_uri() . '/js/custom-gsap-scripts.js', array(), false, true );
}
add_action( 'wp_enqueue_scripts', 'add_gsap_scripts' );
?>

Link to comment
Share on other sites

Hey Jerry,

 

It looks like you enqueue gsap from a child theme and then enqueue your custom-gsap-scripts.js from the parent theme.  If all the scripts are in the child theme you need to use:  get_stylesheet_directory_uri(). 

 

If you do not have a child theme and are modifying or building a custom theme use: get_template_directory_uri().

 

Check the console and make sure they are loading and you are not getting 404 errors.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...