Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1315685
    gorskit74
    Participant

    Hello can i add tracking code in custom>global js??
    thx

    #1315701
    Darshana
    Moderator

    Hi there,

    Thanks for writing in! You can add your JavaScript there without script tags or else you can follow this method.

    Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    Then add the following code into your child theme’s functions.php file.

    
    add_action('wp_head','my_custom_js_code');
    function my_custom_js_code() { ?>
    
    <!-- Replace this line with your JavaScript Code -->
    
    <?php
    }
    

    Hope that helps.

    #1315818
    gorskit74
    Participant

    does it mean that when update is released then this tracking code would be erased (in custom- global js)??
    i did not understand what requires a template chenge ?
    I have set up everything – creating child theme means doing everything from beginning?
    thx

    #1315876
    Darshana
    Moderator

    Hi there,

    Sorry for the confusion. Actually I have mentioned two methods. First method is just to add your code directly into your Custom > JavaScript section. It will not be erased when you update.

    However the second method introduced because it’s lot more cleaner and easy to manage. With regard to child theme setup, you can refer to the following article (https://community.theme.co/kb/how-to-setup-child-themes/).

    Hope that’s clear.

    #1315957
    gorskit74
    Participant

    I am 100% sure the first method is easier I don’t know why You promote the second one ?? the first one doesn’t work properly?

    #1315979
    Darshana
    Moderator

    Hi there,

    Yes, the first method is the easiest way and it will work just fine (make sure to add your code without script tags as follows <script> </script>).

    However when you want to add more customizations, you can follow the second method and it will be easier to manage your code.

    Cheers!

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