WordPress.org

Forums

Customizr
Code in the HEAD section (8 posts)

  1. rosuna
    Member
    Posted 1 year ago #

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

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

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

    Thanks.

  2. tomaja
    Member
    Posted 1 year ago #

    maybe this will help

    function custom_js() {
        echo '<script type="text/javascript" src="http://ads.redcoruna.com/delivery/spcjs.php?id=50"></script>';
    }
    add_action('admin_head', 'custom_js');
    add_action('wp_head', 'custom_js');
  3. rosuna
    Member
    Posted 1 year ago #

    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.

  4. tomaja
    Member
    Posted 1 year ago #

    Ok, it should work with wp_enqueue_script

    function custom_js() {
        wp_enqueue_script('myscript', 'http://ads.redcoruna.com/delivery/spcjs.php?id=50', false, '1.0' );
    }
    add_action ('wp_enqueue_scripts','custom_js');
  5. rosuna
    Member
    Posted 1 year ago #

    It doesn´t work :-(

  6. Andrew
    Forum moderator
    Posted 1 year ago #

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

  7. tomaja
    Member
    Posted 1 year ago #

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

  8. rosuna
    Member
    Posted 1 year ago #

    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='http://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.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags