How to: Add to wp_head From functions.php

11th October 2013

If you’re looking to add elements such as favicons and tracking codes to <head>, the best way forward is to put them together in your functions.php file and then pull through using the wp_head hook. To do this, open up your functions.php and create a new function. It should go something like this (I’ve used the favicon example):

Once you’ve created the function, your next task is to use wp_head to hook it in to the of your theme. To do that, you’re going to need add_action:

Put the two together and you’ll see that your favicon script is loaded just where it needs to be – at the end of your theme .

This method works for all sorts, including pulling through customisable elements from a theme options page like custom colours, typography and tracking codes.

Jo has been looking after my website for a couple of years now. She has just completed another refresh of the site for me, tidying up a few pages and installed a fantastic new booking system that has made a huge improvement to the functionality of the site. I’m really pleased with the result, and the website looks great. I can highly recommend Jo for all your website needs.

(Andrew Tee (Get More Adventure))