{"id":681,"date":"2018-10-13T18:50:47","date_gmt":"2018-10-13T13:20:47","guid":{"rendered":"https:\/\/awpguide.com\/?p=681"},"modified":"2018-10-13T18:50:47","modified_gmt":"2018-10-13T13:20:47","slug":"how-to-add-code-on-wordpress-theme-header","status":"publish","type":"post","link":"https:\/\/awpguide.com\/wp-guides\/how-to-add-code-on-wordpress-theme-header\/","title":{"rendered":"How To Add Code On WordPress Theme Header"},"content":{"rendered":"

Do you want to add code on WordPress header? In this post, we will show you the right method to do it. Last day, one of our users asked about this for adding Google Analytics code and for adding Google AdSense<\/a> code. You don’t need to be techy for doing it. So here’s the post for beginners who need to add code on WordPress theme header.<\/p>\n

Add Code On WordPress Theme Header<\/h2>\n

Typically there are 2 simple methods available for doing it. Both are beginner’s friendly. The first one is by editing the theme files and the second one is by using a dedicated plugin. We are going to cover them both here.<\/p>\n

Theme Editing Method<\/h2>\n

There will be a file in the theme called header.php. All you need to do is, edit the header.php and add your code. First of all, log in to your WordPress dashboard and go to the theme editor.<\/p>\n

\"Add<\/p>\n

From the right side, choose the header.php file. If you are using any child theme<\/a> on your blog, download the header file from the parent theme, upload it on your child theme’s folder. You can use the cPanel file manager or an FTP client for doing it.<\/p>\n

\"twenty<\/p>\n

Add the code just before the <\/head> tag. Simply update the file when you are done.<\/p>\n

\"adding<\/p>\n

You are done! If you change your theme recently, this method will won’t work. Also, use a child theme while using this method. Or, try the next method.<\/p>\n

Plugin Method<\/h2>\n

Go to add new plugins on your dashboard and install Insert Headers and Footers<\/a> plugin.<\/p>\n

\"install<\/p>\n

After installing it, activate the plugin.<\/p>\n

\"insert<\/p>\n

You can find the plugin settings under the settings menu.<\/p>\n

\"insert<\/p>\n

Add the code that you need in the head section and save the changes.<\/p>\n

\"save<\/p>\n

Simple isn’t it? You can view the page source for confirmation.<\/p>\n

No matter if you are on parent theme or changed themes. This plugin will add the code just before the <\/head> tag of every theme.<\/p>\n

We hope you found this post helpful and enjoyed the post. If you did, please consider sharing this post with your friends and fellow bloggers. For more related posts, you need to check out our blog section<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"

Do you want to add code on WordPress header? In this post, we will show you the right method to … <\/p>\n

Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":737,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/awpguide.com\/wp-json\/wp\/v2\/posts\/681"}],"collection":[{"href":"https:\/\/awpguide.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/awpguide.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/awpguide.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/awpguide.com\/wp-json\/wp\/v2\/comments?post=681"}],"version-history":[{"count":0,"href":"https:\/\/awpguide.com\/wp-json\/wp\/v2\/posts\/681\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/awpguide.com\/wp-json\/wp\/v2\/media\/737"}],"wp:attachment":[{"href":"https:\/\/awpguide.com\/wp-json\/wp\/v2\/media?parent=681"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/awpguide.com\/wp-json\/wp\/v2\/categories?post=681"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/awpguide.com\/wp-json\/wp\/v2\/tags?post=681"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}