Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1274146
    josephk99997
    Participant

    Hi,

    I added this code to the functions.php of the child theme:

    // Add script to the footer
    // =============================================================================

    function my_custom_footer_output(){?>

    <script type=”text/javascript”>
    var trackcmp_email = ”;
    var trackcmp = document.createElement(“script”);
    trackcmp.async = true;
    trackcmp.type = ‘text/javascript’;
    trackcmp.src = ‘//trackcmp.net/visit?actid=251724499&e=’+encodeURIComponent(trackcmp_email)+’&r=’+encodeURIComponent(document.referrer)+’&u=’+encodeURIComponent(window.location.href);
    var trackcmp_s = document.getElementsByTagName(“script”);
    if (trackcmp_s.length) {
    trackcmp_s[0].parentNode.appendChild(trackcmp);
    } else {
    var trackcmp_h = document.getElementsByTagName(“head”);
    trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
    }
    </script>

    <?php}

    add_action(‘wp_footer’, ‘my_custom_footer_output’);
    // =============================================================================

    Did I do it right? Or did am I supposed to add a ?> at the end?

    #1274147
    josephk99997
    Participant

    I get this error:

    Parse error: syntax error, unexpected ‘}’ in /home/content/p3pnexwpnas14_data01/21/3063521/html/wp-content/themes/x-child/functions.php on line 48

    #1274150
    josephk99997
    Participant

    I can’t navigate anywhere on the wordpress admin now cos this error keeps coming up.

    #1274160
    josephk99997
    Participant

    My website is totally down now http://www.cloudio.one

    #1274171
    PhotonicPR
    Participant

    Delete the code from your custom child theme functions doc and the theme should reload.

    #1274217
    josephk99997
    Participant

    Site back up again; code deleted. But still need to add that script to the footer. How do I proceed?

    #1274243
    Rupok
    Member

    Hi there,

    You should have fixed that by following the error message. It seems you have placed an unwanted ending and curly brace <?php}. Let’s remove this to get expected result.

    Thanks!

    #1274518
    josephk99997
    Participant

    Here is the correct code:

    // Add script to the footer
    // =============================================================================

    function my_custom_footer_output() {
    ?>

    <script type=”text/javascript”>
    var trackcmp_email = ”;
    var trackcmp = document.createElement(“script”);
    trackcmp.async = true;
    trackcmp.type = ‘text/javascript’;
    trackcmp.src = ‘//trackcmp.net/visit?actid=251724499&e=’+encodeURIComponent(trackcmp_email)+’&r=’+encodeURIComponent(document.referrer)+’&u=’+encodeURIComponent(window.location.href);
    var trackcmp_s = document.getElementsByTagName(“script”);
    if (trackcmp_s.length) {
    trackcmp_s[0].parentNode.appendChild(trackcmp);
    } else {
    var trackcmp_h = document.getElementsByTagName(“head”);
    trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
    }
    </script>

    <?php
    }

    add_action( ‘wp_footer’, ‘my_custom_footer_output’, 99999 );

    ?>

    I will test later if the script is actually tracking anything and report back.

    #1274543
    Paul R
    Moderator

    Glad to know you were able to figure it out. Have a nice day!

    #1275964
    josephk99997
    Participant

    The script is not tracking anything. I think the code I added is wrong.

    Please let me know exactly how to add a script to the footer of every page while working within the child theme. thanks!

    #1275980
    Christian
    Moderator

    The code was added successfully in your footer (see attachment). It might be a problem with your code. Please contact the code provider for further investigation.

    Thanks.

    #1276047
    josephk99997
    Participant

    You’re absolutely 100% correct…thanks! All working perfectly now 🙂

    #1276070
    Christian
    Moderator

    You’re welcome.

  • <script> jQuery(function($){ $("#no-reply-1274146 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>