-
AuthorPosts
-
December 5, 2013 at 3:21 pm #1285
Dudu PParticipantHi,
I need to insert a Pingdom javascript code on the <head> section of the template. Since I haven’t made any modifications on it, I would like to do it the recommended way. What’s that supposed to be?
Cheers and thanks in advance!
December 5, 2013 at 4:53 pm #1293
KoryKeymasterHey Dudu,
Does the Pingdom code have to be in the ‹head› of your site, or can it go towards the bottom near the closing ‹/body›
If it can go near the bottom of your webpage, this is a great thing to use the Custom section of the Customizer for. In this section, you can enter custom CSS or JavaScript to go onto your site. Your CSS changes are echoed out in the ‹head›, and JavaScript is echoed out towards the bottom of your site. This is also the perfect place to place bits of code that you don’t have to manage often, such as Google Analytics code, or your Pingdom snippet. There’s more information on this section in our Video Tutorials section here towards the bottom.
If it needs to go in the ‹head› for certain, let me know and I’ll get back with you on how to do that. It’s slightly more involved, but nothing too crazy. 🙂
December 5, 2013 at 6:12 pm #1327
Dudu PParticipantWow, thanks for the prompt reply! 🙂
So I’ve used the Custom section and it worked great, but unfortunately Pingdom’s script is required to be on the <head> section. A shame, I know… 😛
December 5, 2013 at 8:16 pm #1328
KoryKeymasterNo problem! Alright, so here’s what you’re going to want to do.
1. Download the child themes folder and unzip it to reveal the four child themes inside. Install the child theme for the stack you’re using. Additionally, if you’re using Integrity, make sure to use the correct one depending on which style you’re using (light or dark).
2. Unzip the child theme you’re going to use open the functions.php file inside.
3. Enter in the following snippet of code:
function x_include_pingdom_snippet() { ?> // place your pingdom script here4. Save the file, zip up the child theme, then upload it into your WordPress installation. Simply activate the theme and you're good to go.
Take note that activating the child theme will be like starting with a clean slate in the Customizer, so it would be a good idea to export your current settings and then import them again once you activate the child theme if you've made extensive updates to your site.
Let us know if you run into any issues and we'll make sure to get you up and running!
December 6, 2013 at 2:41 pm #1347
Dudu PParticipantI’ve followed the steps but when I activate the new child-theme I got a blank screen for both the WP Admin and the site itself.
When I remove the code from the functions.php via FTP everything works fine again.
I believe it might be something related to they way the script is declared within the function (I’m not good with PHP syntax):
function x_include_pingdom_snippet() { ?> <script> var _prum = [['id', '529f9a10abe53df61d000000'], ['mark', 'firstbyte', (new Date()).getTime()]]; (function() { var s = document.getElementsByTagName('script')[0] , p = document.createElement('script'); p.async = 'async'; p.src = '//rum-static.pingdom.net/prum.min.js'; s.parentNode.insertBefore(p, s); })(); </script> < ?php } add_action( 'wp_head', 'x_include_pingdom_snippet' );December 6, 2013 at 3:03 pm #1349
KoryKeymasterDudu,
This should work, I just tested it out myself and everything is fine. I think I see what the problem is though. You’ll notice that we close out the end of the function line with ?›. We add back in our opening PHP tag after your script and before the } curly brace with ‹?php. It appears that the formatting is adding in a space after the ‹ and before the ? for this opening PHP tag. Make sure that you remove the space from this opening tag and let me know if that fixes things.
Thanks!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1285 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
