Often you need to add code to WordPress header and footer when trying to integrate with web services like Google Analytics, Google Search Console, etc. The easiest way to add code to the WordPress header and footer is via a plugin called WPCode:
- Login to your WordPress Dashboard and go to Plugins > Add New.
- Search for the WPCode – Insert Headers and Footers + Custom Code Snippets plugin > install and activate it
- Go to Code Snippets (left column) and select Header & Footer (see the screenshot below).
- If you have to insert any code between
<head>
and</head>
, add it to the Header box. - If you have to insert any code just below
<body>
, add it to the Body box. - If you want to add a code above
</body>
, add it to the Footer box.
Once you’re done, don’t forget to click the ‘Save Changes‘ button to save your settings.