Tagged: x
-
AuthorPosts
-
January 4, 2017 at 7:09 am #1315685
gorskit74ParticipantHello can i add tracking code in custom>global js??
thxJanuary 4, 2017 at 7:36 am #1315701
DarshanaModeratorHi 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.
January 4, 2017 at 8:46 am #1315818
gorskit74Participantdoes 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?
thxJanuary 4, 2017 at 9:20 am #1315876
DarshanaModeratorHi 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.
January 4, 2017 at 10:05 am #1315957
gorskit74ParticipantI 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?
January 4, 2017 at 10:22 am #1315979
DarshanaModeratorHi 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!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1315685 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
