• Hi, I am trying to add two script to child theme’s function.php, but it doesn’t work. Can you tell me is this code good?

    
    function wps_adding_scripts() {
      wp_enqueue_script( 'particles','https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js', array('jquery'), true); 
      wp_enqueue_script( 'app', get_template_directory_uri() . 'assets/script.js', array('jquery'), true); 
    
    }
    add_action( 'wp_enqueue_scripts', 'wps_adding_scripts' );
    

    Thanks

    • This topic was modified 3 years, 7 months ago by Nick B..
    • This topic was modified 3 years, 7 months ago by Nick B..
    • This topic was modified 3 years, 7 months ago by Nick B..
    • This topic was modified 3 years, 7 months ago by Nick B..
    • This topic was modified 3 years, 7 months ago by Nick B..
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @dok_h,

    Would you please let us know what is the snippet for? I meant, what were you trying to achieve with that code?

    Kind regards,
    Herman ??

    Thread Starter Nick B.

    (@dok_h)

    Hi,

    I am trying to add particles.js to wordpress. I just want to know if this is the right way to enqueue js script into astra child theme’s function.php.

    Thanks

    • This reply was modified 3 years, 7 months ago by Nick B..

    Hi @dok_h,

    To be honest, I can’t say much about the code itself. However, adding custom code in the child-theme’s functions.php file is the right thing. You might want to check this article about that.

    I hope it will help.

    Kind regards,
    Herman ??

    for a child theme, you’ll want to use get_stylesheet_directory_uri, that will return the currently active theme directory. template_uri will always return the parent theme directory.

    Hi,

    We have actually Astra Child Theme Generator which we can use to create an Astra child theme in just a few clicks.

    And this is a doc that can be used as a reference to know more about what a child theme is.

    I hope it is useful.

    Kind regards,
    Herman ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding script to Astra child theme’ is closed to new replies.