Skip to content

Using WordPress: Add Script to Header

There’s a tricky thing about this idea, “WordPress add header script” I have written down as our topic today. That problem is that “adding a header script” can mean a bunch of things. In our case, I’ll be explaining how a WordPress user (who may be a developer, but doesn’t necessarily understand code that thoroughly) can add a JavaScript file or code to their pages.

We’re not going to discuss how to customize the appearance of your WordPress header or footer. There are other article about that. Instead, we’re just explaining how to add the code snippet that might be the analytics, marketing, or some other “single line of JavaScript” someone needs added to their page. Sound good?

Video Explaining the Best WordPress Plugin to Add Scripts

Because we’re assuming that this task is being some by someone who’s not an expert on PHP or JavaScript development, we’ll use a plugin to add the script to the header of our page. Watch away:

Written Guide of Using a WordPress plugin to Add Header Script

Here’s the basic process we follow in the video above to add JavaScript(s) to our WordPress page headers:

  1. Go to “Plugins > Add New” once you are logged into your WordPress dashboard. (You must be able to install plugins for this to work.)
  2. Search for the “Insert Headers and Footers” plugin from the folks over at WPBeginner. Install and activate that plugin.
  3. Now we’ll use the plugin to add a script to our WordPress head. We’ll need to go to “Settings > Insert Headers and Footers” in the left sidebar once the plugin is running.
  4. Depending on whether your script needs to be added to your page headers or footers, you’ll paste it into the appropriate box. Then press “Save.”

With those step, your done. You’re all set to get your WordPress header scripts running on the pages your visitors see. Hopefully that wasn’t too hard.

Yay! 🎉 You made it to the end of the article!
David Hayes
Share:

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!