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.

Leave a Reply

Jo took my simple brief outline of what I wanted and turned it into everything I wanted and more. Jo was very professional, efficient and she was patient and understanding with the fact that I was not knowledgeable about building websites or what’s involved. By the end of it Jo had given me and my team a training session around how to manage the website. I would highly recommend her!

Sharon Mulholland (Sandcastle Mortgages)