Once you have your child theme ready to go, you can proceed with the following steps to add code to your theme’s header or footer. But if your developer doesn’t, here’s a guide on how to create a WordPress child theme. If you don’t use a child theme, any code that you add to your header or footer will get overwritten if you update your WordPress theme. If you want to proceed with this method over the plugin in the previous section, it’s essential that you use a WordPress child theme to make your edits. In this section, you’ll learn how to manually add code snippets to your theme’s header and footer via its functions.php file. The manual method might be overly complicated for you. If you’re not familiar with the basics of PHP, we recommend you stick with the plugin method above. How to Manually Add Code to WordPress Header and Footer It currently has over 100,000 active installs with a 5 out of 5-star rating. It removes the need to add custom snippets to your theme’s functions.php file. If you are simply needing to add different PHP functions on a site-wide basis, we also recommend checking out the free Code Snippets plugin. To do it, head to the AMP tab in Header and Footer and paste your code snippet into the appropriate box: Google AMP interface BONUS – Add Code to Header and Footer of Google AMP PagesĪnother neat thing about this plugin is that, if you’re using 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 ( as long as you’re using the official AMP plugin from Automattic). If needed, you can add multiple code snippets to each box. ![]() If you just want to add a code snippet to the footer section for all users, no matter their devices, paste it in the Desktop box and leave Mobile unchecked: Example of adding code to footer
0 Comments
Leave a Reply. |