• Resolved larnoult

    (@larnoult)


    Hello,

    I’ve got a JQuery script that works ok when included manually in a page, but I’d like now to include it in every pages. I’m running a Virtue child theme. I tried to edit the head.php document of the virtue theme and added
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/scripts/myscript.js"></script>
    somewhere within the <head> tag, but without success.

    Any suggestion would be more than welcome ?? Thanks a lot in advance!

    Laurent

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey,
    First I recommend using a plugin for this, and if not a plugin then a function. You don’t want to have to override the head.php file if you can help it.

    The function would look like this, you can add to your child theme functions.php file

    function my_custom_scripts() {
    wp_register_script('myscript', get_stylesheet_uri(). '/scripts/myscript.js', false, true);
    wp_enqueue_script('myscript');
    }
    add_action('wp_enqueue_scripts', 'my_custom_scripts', 100);

    Kadence Themes

    Thread Starter larnoult

    (@larnoult)

    Hi,

    Thanks for the quick answer; adding your script to my functions.php did not work … I went for the CSS & JavaScript Toolbox that made it.
    I am seriously considering shifting to the pro version; your support is really great!

    Cheers,

    Laurent

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Include javascript header?’ is closed to new replies.