New Landing How can we help? Themeforest Theme Support Dante Adding Script to (header.php)

Viewing 5 posts - 1 through 5 (of 5 total)
  • Posted in: Dante
  • #103163
    Brookebot
    Member
    Post count: 112

    I need to add a google analytics content experiment plugin code to the header. If I add code to Theme Options under “Custom JS: Add some custom JavaScript to your theme by adding it to this textarea.” will this code be placed in the header or in the footer?

    Plugin: http://wordpress.org/plugins/google-content-experiments/installation/

    Steps plugin advises me to take:
    1. Within your theme, locate the file where the <head> tag is inserted (probably something like header.php)

    2. Place <?php do_action( ‘wpe_gce_head’ ); ?> right after <head>

    3. Save the file

    #103176
    Brookebot
    Member
    Post count: 112

    I just realized it’s not a script, it’s php! AHH! LOL So, now my question is:

    How do I add this to the <head> without having to copy the header.php to my child theme. That scares me ONLY because I’m afraid that y’all will make changes to the header.php in theme updates & I will be missing some kind of functionality because I will have a copy of the old header.php header being used in my child theme w/ this <?php do_action( ‘wpe_gce_head’ ); ?> add to it. So, is there a place I can add php to the head of every page within the theme options settings? OR maybe there is something I can add to my child functions.php?

    #103226
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    First of all something that I realized is that the plugin isn’t updated since last year.
    Also don’t understand why the developer didn’t hooked is own function to the Head of the page.

    Please procedure at your own risk. You can add the code bellow in your child theme functions.php

    
    add_action('wp_head','hook_google_content_experiments');
    
    function hook_google_content_experiments(){
    do_action( 'wpe_gce_head' );
    return;
    }
    

    This is just an example how to add something to the “Head”
    We can’t support any problem caused by this plugin.

    -Rui

    #103612
    Brookebot
    Member
    Post count: 112

    Excellent, yes I understand completely that you are not responsible for plugin not working! Thank you so much!

    #103637
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Thanks Rui!

    – Ed

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

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register