{"id":73,"date":"2019-05-05T15:43:10","date_gmt":"2019-05-05T15:43:10","guid":{"rendered":"https:\/\/wpproonline.com\/?p=73"},"modified":"2026-02-26T10:51:48","modified_gmt":"2026-02-26T10:51:48","slug":"how-to-add-code-to-wordpress-header-and-footer","status":"publish","type":"post","link":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/","title":{"rendered":"How to Add Code to WordPress Header and Footer"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Struggling with the way to add code to the WordPress header or footer? Several tools and trailing scripts need you to feature code snippets to your WordPress site\u2019s header or footer. But, by default, WordPress doesn\u2019t build it terribly accessible to edit those files. during this entry, we\u2019ll show you the way to feature code to the WordPress header or footer each by employing a WordPress plugin or manually adding the code to your functions.php file. for many users, the plugin technique is that the suggested technique. however intermediate-advanced WordPress users could like mistreatment the manual code technique, instead.<\/p>\n\n<p><!--more--><\/p>\n\n<p class=\"wp-block-paragraph\">You can click the links below to jump straight to your preferred method:<\/p>\n\n<ul class=\"wp-block-list\">\n<li><a href=\"\/#plugin\">How to Add Code to WordPress Header and Footer With a Plugin<\/a><\/li>\n<li><a href=\"\/#manual\">How to Manually Add Code to WordPress Header and Footer<\/a><\/li>\n<\/ul>\n\n<h2 class=\"wp-block-heading\">How to Add Code to WordPress Header and Footer With a Plugin<\/h2>\n\n<p class=\"wp-block-paragraph\">For most users, the easiest way to add code to the WordPress header and footer is via a plugin. The benefits of using a plugin over the manual method in the next section are:<\/p>\n\n<ul class=\"wp-block-list\">\n<li>Your code snippets will remain intact if you ever switch themes<\/li>\n<li>The plugin makes it easy to only add code snippets to the header or footer of\u00a0<strong>your homepage<\/strong>, which can be helpful for some uses.<\/li>\n<li>The plugin is more beginner-friendly because it doesn\u2019t require digging into code<\/li>\n<\/ul>\n\n<p class=\"wp-block-paragraph\">While there are several plugins that offer this functionality, we recommend the\u00a0<a href=\"https:\/\/wordpress.org\/plugins\/header-footer\/\" target=\"_blank\" rel=\"noopener noreferrer\">Head, Footer and Post Injections plugin<\/a>\u00a0from Stefano Lissa because it gives you more control than many of the alternatives. It currently has over 100,000 active installs with a 5 out of 5-star rating.<\/p>\n\n<figure><a href=\"https:\/\/wordpress.org\/plugins\/header-footer\/\" rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/digitalhubz.com\/wppro-app\/app-data\/uploads\/2019\/05\/header-and-footer-wordpress-plugin-1024x329.png\" alt=\"Header and Footer WordPress plugin\" \/><\/a>\n<figcaption>Header and Footer WordPress plugin<\/figcaption>\n<\/figure>\n\n<h3 class=\"wp-block-heading\">Step 1: Install and Activate Head, Footer and Post Injections<\/h3>\n\n<p class=\"wp-block-paragraph\">Head, Footer and Post Injections is available for free at WordPress.org, so you can\u00a0install and activate it\u00a0directly from your WordPress dashboard by going to\u00a0<strong>Plugins \u2192 Add New<\/strong>\u00a0and searching for it:<\/p>\n\n<figure><img decoding=\"async\" src=\"https:\/\/digitalhubz.com\/wppro-app\/app-data\/uploads\/2019\/05\/add-code-wordpress-header-footer.png\" alt=\"\" \/><\/figure>\n\n<h3 class=\"wp-block-heading\">Step 2: Add Code Snippet to Head, Footer and Post Injections<\/h3>\n\n<p class=\"wp-block-paragraph\">Once you activate the plugin, you can access its interface by going to\u00a0<strong>Settings \u2192 Header and Footer\u00a0<\/strong>in your WordPress dashboard. You\u2019ll see a number of tabs in the plugin\u2019s interface. But for this guide, you\u2019ll mostly work in the default\u00a0<strong>Head and footer<\/strong>\u00a0tab:<\/p>\n\n<figure><img decoding=\"async\" src=\"https:\/\/digitalhubz.com\/wppro-app\/app-data\/uploads\/2019\/05\/add-code-wordpress-header-footer-2-1024x592.png\" alt=\"\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">To add code to your site\u2019s header, you need to paste it into one of the boxes under the\u00a0<strong>&lt;HEAD&gt; SECTION INJECTION<\/strong>\u00a0area:<\/p>\n\n<ul class=\"wp-block-list\">\n<li><strong>Every page<\/strong>\u00a0\u2013 adds the code snippet to the header of every single page on your site.\u00a0<strong>This is what you\u2019ll want to use most of the time.<\/strong><\/li>\n<li><strong>Only home page<\/strong>\u00a0\u2013 only adds the code snippet to the header of your homepage.<\/li>\n<\/ul>\n\n<p class=\"wp-block-paragraph\">For example, to\u00a0<em><strong>add the Google Analytics tracking code to WordPress<\/strong><\/em>, you\u2019d just paste it into the\u00a0<strong>Every page<\/strong>\u00a0box and save your changes:<\/p>\n\n<figure><img decoding=\"async\" src=\"https:\/\/digitalhubz.com\/wppro-app\/app-data\/uploads\/2019\/05\/add-code-wordpress-header-footer-3-1024x392.png\" alt=\"\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">To add code to your site\u2019s footer, you can scroll down to the\u00a0<strong>BEFORE THE &lt;\/BODY&gt; CLOSING TAG (FOOTER)<\/strong>\u00a0option. Again, you have two options, though they\u2019re different from the header section:<\/p>\n\n<ul class=\"wp-block-list\">\n<li><strong>Desktop \u2013\u00a0<\/strong>despite the name, this adds code to the footer of both the desktop and mobile version of your site<strong>\u00a0unless you specifically check the box for Mobile.<\/strong><\/li>\n<li><strong>Mobile<\/strong>\u00a0\u2013\u00a0<em>when checked,<\/em>\u00a0this lets you add a different code snippet to the mobile version of your site.<\/li>\n<\/ul>\n\n<p class=\"wp-block-paragraph\">If you just want to add a code snippet to the footer section for\u00a0<strong>all users,<\/strong>\u00a0no matter their devices, paste it in the\u00a0<strong>Desktop<\/strong>\u00a0box and leave\u00a0<strong>Mobile<\/strong>\u00a0<em>unchecked<\/em>:<\/p>\n\n<figure><img decoding=\"async\" src=\"https:\/\/digitalhubz.com\/wppro-app\/app-data\/uploads\/2019\/05\/add-code-wordpress-header-footer-4-1024x372.png\" alt=\"\" \/><\/figure>\n\n<h3 class=\"wp-block-heading\">BONUS \u2013 Add Code to Header and Footer of Google AMP Pages<\/h3>\n\n<p class=\"wp-block-paragraph\">Another neat thing about this plugin is that, if you\u2019re\u00a0using Google AMP for WordPress, the plugin lets you specifically add code snippets to the header and footer of the Google AMP versions of your pages (<em>as long as you\u2019re using the\u00a0<\/em><a href=\"https:\/\/wordpress.org\/plugins\/amp\/\" target=\"_blank\" rel=\"noopener noreferrer\"><em>official AMP plugin from Automattic<\/em><\/a>).<\/p>\n\n<p class=\"wp-block-paragraph\">To do it, head to the\u00a0<strong>AMP<\/strong>\u00a0tab in\u00a0<strong>Header and Footer<\/strong>\u00a0and paste your code snippet into the appropriate box:<\/p>\n\n<figure><img decoding=\"async\" src=\"https:\/\/digitalhubz.com\/wppro-app\/app-data\/uploads\/2019\/05\/add-code-wordpress-header-footer-5-1024x536.png\" alt=\"\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">If you are simply needing to add different PHP functions on a site-wide basis, we also recommend checking out the free\u00a0<a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" target=\"_blank\" rel=\"noopener noreferrer\">Code Snippets plugin<\/a>.\u00a0It removes the need to add custom snippets to your theme\u2019s functions.php file. It currently has over 50,000 active installs with a 5 out of 5-star rating.<\/p>\n\n<figure><img decoding=\"async\" src=\"https:\/\/digitalhubz.com\/wppro-app\/app-data\/uploads\/2019\/05\/code-snippets-wordpress-plugin-1024x329.jpg\" alt=\"\" \/><\/figure>\n\n<h2 class=\"wp-block-heading\">How to Manually Add Code to WordPress Header and Footer<\/h2>\n\n<p class=\"wp-block-paragraph\"><em>If you\u2019re not familiar with the basics of PHP, we recommend you stick with the plugin method above. The manual method might be overly complicated for you.<\/em><\/p>\n\n<p class=\"wp-block-paragraph\">In this section, you\u2019ll learn how to manually add code snippets to your theme\u2019s header and footer via its functions.php file.<\/p>\n\n<p class=\"wp-block-paragraph\">If you want to proceed with this method over the plugin in the previous section, it\u2019s essential that you use a WordPress child theme to make your edits. If you don\u2019t use a child theme, any code that you add to your header or footer\u00a0<strong>will get overwritten if you update your WordPress theme<\/strong>.<\/p>\n\n<p class=\"wp-block-paragraph\">Many developers provide a child theme. But if your developer doesn\u2019t, here\u2019s a guide on\u00a0<a href=\"\/\" target=\"_blank\" rel=\"noopener noreferrer\">how to create a WordPress child theme<\/a>. Once you have your child theme ready to go, you can proceed with the following steps to add code to your theme\u2019s header or footer.<\/p>\n\n<p class=\"wp-block-paragraph\">While you can add code snippets directly to your\u00a0<strong>header.php<\/strong>\u00a0and\u00a0<strong>footer.php<\/strong>\u00a0files, a better way is to use your\u00a0<strong>functions.php<\/strong>\u00a0file and the appropriate WordPress hook. This lets you keep all your snippets in one place and avoid modifying core theme files.<\/p>\n\n<h3 class=\"wp-block-heading\">Step 1: Prepare Code Snippets<\/h3>\n\n<p class=\"wp-block-paragraph\">To get you started, we\u2019ll give you a rough framework to add code to both your header and footer.<\/p>\n\n<p class=\"wp-block-paragraph\"><strong>To add code to your header, use this code snippet:<\/strong><\/p>\n\n<pre data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/* Describe what the code snippet does so you can remember later on *\/\nadd_action('wp_head', 'your_function_name');\nfunction your_function_name(){\n?&gt;\nPASTE HEADER CODE HERE\n&lt;?php\n};<\/pre>\n\n<p class=\"wp-block-paragraph\"><strong>To add code to your footer, use this code snippet:<\/strong><\/p>\n\n<pre data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/* Describe what the code snippet does so you can remember later on *\/\nadd_action('wp_footer', 'your_function_name');\nfunction your_function_name(){\n?&gt;\nPASTE HEADER CODE HERE\n&lt;?php\n};<\/pre>\n\n<p class=\"wp-block-paragraph\">For each snippet, make sure to change:<\/p>\n\n<ul class=\"wp-block-list\">\n<li>The comment description (<em>helpful when you need to remember what a code snippet does a year later<\/em>)<\/li>\n<li>The\u00a0<em>your_function_name<\/em>\u00a0placeholder (both instances)<\/li>\n<li>The\u00a0<em>PASTE X CODE HERE<\/em>\u00a0placeholder<\/li>\n<\/ul>\n\n<h3 class=\"wp-block-heading\">Step 2: Add Code Snippets to functions.php File in Child Theme<\/h3>\n\n<p class=\"wp-block-paragraph\">Once you have the relevant code snippet(s) ready, you need to add them to the\u00a0<strong>functions.php<\/strong>\u00a0file of your child theme. You can either edit this file by connecting to your site via FTP. Or, you can go to\u00a0<strong>Appearance \u2192 Editor<\/strong>\u00a0and select the\u00a0<strong>functions.php<\/strong>\u00a0file. Then, paste your code at the end of the file:<\/p>\n\n<figure><img decoding=\"async\" src=\"https:\/\/digitalhubz.com\/wppro-app\/app-data\/uploads\/2019\/05\/add-code-wordpress-header-footer-6-1024x564.png\" alt=\"\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">Make sure to save your changes and you\u2019re done!<\/p>\n\n<h3 class=\"wp-block-heading\">BONUS: Add Code to Header or Footer For Only Specific Pages<\/h3>\n\n<p class=\"wp-block-paragraph\">If you want more control over where your header or footer code snippets show up, you can use\u00a0<em>if<\/em>\u00a0statements to only add the code to specific pages on your WordPress site.<\/p>\n\n<p class=\"wp-block-paragraph\">For example, to\u00a0<strong>only add code snippets to the header or footer of your homepage<\/strong>, you could use:<\/p>\n\n<pre data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/* Describe what the code snippet does so you can remember later on *\/\nadd_action('wp_head', 'your_function_name');\nfunction your_function_name(){\nif(is_single(73790)) {  ?&gt;\nPASTE HEADER CODE HERE\n&lt;?php  }\n};<\/pre>\n\n<p class=\"wp-block-paragraph\">Another option is to\u00a0<strong>only add the code snippets to<\/strong>\u00a0<strong>specific posts or pages<\/strong>. To do that, you can use this code snippet:<\/p>\n\n<pre data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/* Describe what the code snippet does so you can remember later on *\/\nadd_action('wp_footer', 'your_function_name');\nfunction your_function_name(){\nif(is_single(73790)) {  ?&gt;\nPASTE HEADER CODE HERE\n&lt;?php  }\n};<\/pre>\n\n<p class=\"wp-block-paragraph\">Make sure to replace the example number \u2013 73790 \u2013 with the\u00a0actual ID of the post or page\u00a0you want to add the code snippets to.<\/p>\n\n<h2 class=\"wp-block-heading\">When In Doubt, Use The Plugin<\/h2>\n\n<p class=\"wp-block-paragraph\">That wraps up our guide on how to add code to the header or footer of your WordPress site. If the manual code examples are confusing, we recommend that you use the plugin method. It\u2019s much more beginner-friendly and, most of the time, gives you just as much functionality.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Struggling with the way to add code to the WordPress header or footer? Several tools and trailing scripts need you to feature code snippets to your WordPress site\u2019s header or&hellip;<\/p>\n","protected":false},"author":1,"featured_media":52444,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[89,72],"tags":[87,88,90],"class_list":["post-73","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","category-wordpress","tag-foooter","tag-header","tag-wp_head"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Add Code to WordPress Header and Footer - DigitalHubZ<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Add Code to WordPress Header and Footer\" \/>\n<meta property=\"og:description\" content=\"Struggling with the way to add code to the WordPress header or footer? Several tools and trailing scripts need you to feature code snippets to your WordPress site\u2019s header or&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/\" \/>\n<meta property=\"og:site_name\" content=\"DigitalHubZ\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-05T15:43:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-26T10:51:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.digitalhubz.com\/blog\/wp-content\/uploads\/2019\/05\/add-code-wordpress-header-footer-7.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1460\" \/>\n\t<meta property=\"og:image:height\" content=\"730\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"DigitalHubZ\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DigitalHubZ\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/\"},\"author\":{\"name\":\"DigitalHubZ\",\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/#\\\/schema\\\/person\\\/5a4074d837d6e5d22d665e5b7ca9e873\"},\"headline\":\"How to Add Code to WordPress Header and Footer\",\"datePublished\":\"2019-05-05T15:43:10+00:00\",\"dateModified\":\"2026-02-26T10:51:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/\"},\"wordCount\":1268,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/add-code-wordpress-header-footer-7.png\",\"keywords\":[\"foooter\",\"header\",\"wp_head\"],\"articleSection\":[\"PHP\",\"Wordpress\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/\",\"url\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/\",\"name\":\"How to Add Code to WordPress Header and Footer - DigitalHubZ\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/add-code-wordpress-header-footer-7.png\",\"datePublished\":\"2019-05-05T15:43:10+00:00\",\"dateModified\":\"2026-02-26T10:51:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/add-code-wordpress-header-footer-7.png\",\"contentUrl\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/add-code-wordpress-header-footer-7.png\",\"width\":1460,\"height\":730},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/how-to-add-code-to-wordpress-header-and-footer\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Add Code to WordPress Header and Footer\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/\",\"name\":\"DigitalHubZ\",\"description\":\"Future-Ready Digital Solutions\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/#organization\",\"name\":\"DigitalHubZ\",\"url\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/03\\\/digitalhubz.webp\",\"contentUrl\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/03\\\/digitalhubz.webp\",\"width\":1232,\"height\":369,\"caption\":\"DigitalHubZ\"},\"image\":{\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/#\\\/schema\\\/person\\\/5a4074d837d6e5d22d665e5b7ca9e873\",\"name\":\"DigitalHubZ\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/414c5bb85907e15e0f840541718ecc7420d52ea432b33f6a57761a674a52ebb7?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/414c5bb85907e15e0f840541718ecc7420d52ea432b33f6a57761a674a52ebb7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/414c5bb85907e15e0f840541718ecc7420d52ea432b33f6a57761a674a52ebb7?s=96&d=mm&r=g\",\"caption\":\"DigitalHubZ\"},\"sameAs\":[\"https:\\\/\\\/digitalhubz.com\"],\"url\":\"https:\\\/\\\/www.digitalhubz.com\\\/blog\\\/author\\\/digi_v1_wp\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Add Code to WordPress Header and Footer - DigitalHubZ","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/","og_locale":"en_US","og_type":"article","og_title":"How to Add Code to WordPress Header and Footer","og_description":"Struggling with the way to add code to the WordPress header or footer? Several tools and trailing scripts need you to feature code snippets to your WordPress site\u2019s header or&hellip;","og_url":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/","og_site_name":"DigitalHubZ","article_published_time":"2019-05-05T15:43:10+00:00","article_modified_time":"2026-02-26T10:51:48+00:00","og_image":[{"width":1460,"height":730,"url":"https:\/\/www.digitalhubz.com\/blog\/wp-content\/uploads\/2019\/05\/add-code-wordpress-header-footer-7.png","type":"image\/png"}],"author":"DigitalHubZ","twitter_card":"summary_large_image","twitter_misc":{"Written by":"DigitalHubZ","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/#article","isPartOf":{"@id":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/"},"author":{"name":"DigitalHubZ","@id":"https:\/\/www.digitalhubz.com\/blog\/#\/schema\/person\/5a4074d837d6e5d22d665e5b7ca9e873"},"headline":"How to Add Code to WordPress Header and Footer","datePublished":"2019-05-05T15:43:10+00:00","dateModified":"2026-02-26T10:51:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/"},"wordCount":1268,"commentCount":0,"publisher":{"@id":"https:\/\/www.digitalhubz.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/#primaryimage"},"thumbnailUrl":"https:\/\/www.digitalhubz.com\/blog\/wp-content\/uploads\/2019\/05\/add-code-wordpress-header-footer-7.png","keywords":["foooter","header","wp_head"],"articleSection":["PHP","Wordpress"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/","url":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/","name":"How to Add Code to WordPress Header and Footer - DigitalHubZ","isPartOf":{"@id":"https:\/\/www.digitalhubz.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/#primaryimage"},"image":{"@id":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/#primaryimage"},"thumbnailUrl":"https:\/\/www.digitalhubz.com\/blog\/wp-content\/uploads\/2019\/05\/add-code-wordpress-header-footer-7.png","datePublished":"2019-05-05T15:43:10+00:00","dateModified":"2026-02-26T10:51:48+00:00","breadcrumb":{"@id":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/#primaryimage","url":"https:\/\/www.digitalhubz.com\/blog\/wp-content\/uploads\/2019\/05\/add-code-wordpress-header-footer-7.png","contentUrl":"https:\/\/www.digitalhubz.com\/blog\/wp-content\/uploads\/2019\/05\/add-code-wordpress-header-footer-7.png","width":1460,"height":730},{"@type":"BreadcrumbList","@id":"https:\/\/www.digitalhubz.com\/blog\/how-to-add-code-to-wordpress-header-and-footer\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.digitalhubz.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Add Code to WordPress Header and Footer"}]},{"@type":"WebSite","@id":"https:\/\/www.digitalhubz.com\/blog\/#website","url":"https:\/\/www.digitalhubz.com\/blog\/","name":"DigitalHubZ","description":"Future-Ready Digital Solutions","publisher":{"@id":"https:\/\/www.digitalhubz.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.digitalhubz.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.digitalhubz.com\/blog\/#organization","name":"DigitalHubZ","url":"https:\/\/www.digitalhubz.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.digitalhubz.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.digitalhubz.com\/blog\/wp-content\/uploads\/2023\/03\/digitalhubz.webp","contentUrl":"https:\/\/www.digitalhubz.com\/blog\/wp-content\/uploads\/2023\/03\/digitalhubz.webp","width":1232,"height":369,"caption":"DigitalHubZ"},"image":{"@id":"https:\/\/www.digitalhubz.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.digitalhubz.com\/blog\/#\/schema\/person\/5a4074d837d6e5d22d665e5b7ca9e873","name":"DigitalHubZ","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/414c5bb85907e15e0f840541718ecc7420d52ea432b33f6a57761a674a52ebb7?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/414c5bb85907e15e0f840541718ecc7420d52ea432b33f6a57761a674a52ebb7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/414c5bb85907e15e0f840541718ecc7420d52ea432b33f6a57761a674a52ebb7?s=96&d=mm&r=g","caption":"DigitalHubZ"},"sameAs":["https:\/\/digitalhubz.com"],"url":"https:\/\/www.digitalhubz.com\/blog\/author\/digi_v1_wp\/"}]}},"_links":{"self":[{"href":"https:\/\/www.digitalhubz.com\/blog\/wp-json\/wp\/v2\/posts\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.digitalhubz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.digitalhubz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.digitalhubz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.digitalhubz.com\/blog\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":4,"href":"https:\/\/www.digitalhubz.com\/blog\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":54931,"href":"https:\/\/www.digitalhubz.com\/blog\/wp-json\/wp\/v2\/posts\/73\/revisions\/54931"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.digitalhubz.com\/blog\/wp-json\/wp\/v2\/media\/52444"}],"wp:attachment":[{"href":"https:\/\/www.digitalhubz.com\/blog\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.digitalhubz.com\/blog\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.digitalhubz.com\/blog\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}