Importing new js scripts in head tag over child theme

  • Luko

    #6364

    Hy, everyone

    Does someone have experience with similar issue? I need to include few custum made js files in head tag. So I find out that this theme does it with wp_register_script that is in ../includes/theme-scripts.php.

    I assume that I need to put php code in my child theme functions.php and register new scripts, but just don’t know how.

    With wp_enqueue_script function ? Or…

    It’s to complex for my current php status 🙂 so I kindly ask for help with this….

    Thanks in advance!

    Prasanna SP

    #34123

    Yes, I’ve done the similar thing to add quicktags-toolbar to comment form. It’s pretty easy to do with child theme.

    I’m on mobile right now. So, can’t write in detail. Will give a better answer tomorrow when I get my PC 🙂

    Luko

    #34124

    Well, I actually did it like this:

    <?php
    function my_scripts_method() {
    wp_enqueue_script(
    'custom-script',
    get_stylesheet_directory_uri() . '/js/custom_script.js',
    array('jquery')
    );
    }
    add_action('wp_enqueue_scripts', 'my_scripts_method');
    ?>

    This code ended in my child-theme functions.php file.

    It didn’t work 🙂 but, it’s showing out in head section so problem is somewhere else … 🙁

    Prasanna SP

    #34125

    Enqueuing is done right. So, it seems the problem is with JS itself.

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

You must be logged in to reply to this topic.