Struggling with custom javascript queue in functions.php

  • mag

    #7259

    The following code worked perfectly in the child theme’s functions.php

    Thanks so much!

    I marked the thread resolved and reopened it and I wasn’t sure if I should start a new thread. Sorry if I am messing up the protocol.

    Now we are looking to add another script and I can’t figure out how to make that happen. I’ve read docs online and just can’t seem to get it right. Hoping to get some advice again. So sorry to be a pain.

    Here’s the code that works, want to add another script; newscript.js

    <?php
    /**
    * Enqueue custom scripts
    */
    function my_enqueue_scripts(){
    if ( ! is_admin() ) {
    wp_enqueue_script( 'acac1', get_stylesheet_directory_uri() . '/acac1.js', array(), false );
    }
    }
    add_action( 'wp_enqueue_scripts', 'my_enqueue_scripts' );

    mag

    #37621

    I figured this out.

    I don’t know why it wasn’t working previously but I tried again and added another line after the first with the second script listed…

    wp_enqueue_script( 'acac1', get_stylesheet_directory_uri() . '/acac1.js', array(), false );
    wp_enqueue_script( 'newscript', get_stylesheet_directory_uri() . '/newscript.js', array(), false );

    It is working now. I hope it is correctly formatted. It must have been a typo.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.