Support » Fixing WordPress » Trying to add some javascript in the head, and can't.

  • I’m trying to add a tracker script into the header.php of my website, In Appearance > Editor, I’ve inserted some dummy JS to see if it shows up:

    <script type="text/javascript">
      function(test_null_thingy) {

    And flushed Varnish, reloaded, and it’s not there. I’m not using CloudFlare or any other caching plugins. I’m probably doing something wrong here, but what?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Are you working with a child theme? Because if you are editing the theme files directly, your changes will be lost the next time the theme is updated. And by the way, header.php does not make changes to the <head> section of a web page. It is responsible for creating the header of a page, which usually includes the site title, logo, and navigation menu.

    When I do a view source on your site, I don’t see your dummy JS, but I do see a script for Google Analytics. How did you get that in there? Just use the same mechanism. One plugin that you might want to try is Header and Footer. I use it to insert Javascript like Google Analytics.

    Thanks CrouchingBruin. I’m not working with a child theme as far as I know – I didn’t design the site, but it seems to be the Steakhouse theme.

    I only tried header.php as it contains everything from <!DOCTYPE html> into the body’s <div> elements, but I’m probably looking in the wrong place. I’ll try that plugin though, probably safer!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trying to add some javascript in the head, and can't.’ is closed to new replies.