How To Add Header And Footer Code In WordPress Themes

Home / How To Add Header And Footer Code In WordPress Themes

Image

You will learn easy and fast methods to add code in the WordPress Header and Footer. You will find the easiest way to add code with or without the use of a plugin.

When you design your WordPress site at some point you may need to use code snippets in herder and footer of the theme.

Some WordPress themes have in-built feature to add code or script into header and footer file like Themify, ElegantThemes.

 

Which type of Code Snippets and Scripts you may need to add to WP Header & Footer

You might want to add one or more type of codes in the WordPress header and footer out of the followings.

  • Google Analytics tracking code. – The Analytics tracking code is a snippet (code) of JavaScript that collects and sends data to Analytics from a website.
  • Site Security Verification code.
  • Webmaster Tools Verification Meta tags.
  • Verification code for Bing, Alexa, Yandex, etc.
  • Schema mark-ups – Schema markup is code that you put on your website to help the search engines return informative results for users.
  • Any other script or code. (Javascript, CSS, HTML, PHP)

 

Ways To Add Code in WordPress Header and Footer 

  • Add Manually – Editing your theme’s header.php and footer.php files
  • Using a Plugin – Easily add code snippets without losing any other code
  • Themes Inbuilt feature – Only some themes offer this feature but not all

 

    1. Add Manually The first option is not for beginner because it requires you to add header and footer code by directly so you need some basic skill in the coding. A disadvantage of using this method is that your code will be removed if you install an update to your theme or your site may go down with any critical error.
      When you trying to add the code manually don’t forgot to take a complete backup if something went wrong you can restore your data.

      1. Go to WordPress Dashboard Appearance > Editor.
      2. Then Open header.php or footer.php file.
      3. Now you can add, edit or delete your code
      4. Click Update File. And you’re done.Note – I recommend you should apply this method to the child theme files instead of parent theme files.

       

    2. Using a Plugin
      Add code to WP header and footer using WordPress Plugins is recommended and safe option and it is very easy too. There is a lot of free plugins that work with all free and premium WordPress themes.

      Insert Headers and Footers

      insert-header-footer-code
      Insert Headers and Footers is a simple plugin its is let you insert code into the header and footer files of WordPress themes. This plugin is free and simple with a great user interface. You can also add code like Google Analytics, custom CSS, Facebook Pixel, and more.
      How It WorksFirst, you need to install and activate the plugin. After installed successfully you need to go Settings » Insert Headers and Footers from your admin panel. Then you will see two small areas to add your code to herder and footer files.

      Insert Headers and Footers

      Insert Headers and Footers

Head, Footer and Post Injections
This plugin allows inserting the code into the head and footer part and before and after the content part of the blog posts.

  1. You can add custom code (Javascript, CSS, HTML) to the head (<head>) section of every blog web page.
  2. Add custom code to the head section only on the home page (eg. Google Webmaster verification code)
  3. you can add custom code on the footer (before the </body>) of each blog web page.
  4. Codes can contain PHP parts that will be executed to add injection logic (minimum programming skills needed)
  5. Add custom code before and after each post content
  6. Add custom code before and after each page content
  7. Optionally add the Facebook tag so a like on a post will be shown with the thumbnail or first post image
  8. Configurable default image for Facebook tag for posts without an image
  9. Facebook tag for home and generic web pages
  10. bbPress compatibility: the  tag will be filled with the first forum (see the FAQ)

I hope this post will be useful to you, and you found the easy way to add code snippet in the header or footer files. it depends on you that which method you are using if you follow the steps carefully it is not a big deal to add code into header footer files.

About Author

about author

brosoftsystem

Bro Soft System is a business site, we develop the site for client requirement. like That fashion site, blog site, business site, and Woocommerce and e-commerce compatible site, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *