• I need to insert one line of code in the HEAD section. This one:

    <script type='text/javascript' src='https://ads.redcoruna.com/delivery/spcjs.php?id=50'></script>

    Is it possible to do it using the child theme I have created?

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • maybe this will help

    function custom_js() {
        echo '<script type="text/javascript" src="https://ads.redcoruna.com/delivery/spcjs.php?id=50"></script>';
    }
    add_action('admin_head', 'custom_js');
    add_action('wp_head', 'custom_js');

    Thread Starter rosuna

    (@rosuna)

    Thank you but I have added that code to the functions.php file in the child theme, I have deleted the cache, and it seems that ir is not working.

    The line of code is not in the HEAD section when I look at the web source code.

    Ok, it should work with wp_enqueue_script

    function custom_js() {
        wp_enqueue_script('myscript', 'https://ads.redcoruna.com/delivery/spcjs.php?id=50', false, '1.0' );
    }
    add_action ('wp_enqueue_scripts','custom_js');

    Thread Starter rosuna

    (@rosuna)

    It doesn′t work ??

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    What do you mean by doesn’t work, is your JS file loaded in the page first?

    I just checked it on my testing site and it works, it loads the script to the head

    Thread Starter rosuna

    (@rosuna)

    When I write this line in the class-header-header_main.php file (in the Customizr theme), it is shown when I look at the web source code using any browser.

    <script type='text/javascript' src='https://ads.redcoruna.com/delivery/spcjs.php?id=50'></script>

    But I prefer not to change the Customizr theme and if I modify the functions.php in the child theme as you suggest, I can′t see that line in the web source code.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Code in the HEAD section’ is closed to new replies.