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

What our customers say:

I was lost in a sea of technical jargon and hosting gobbledygook until Jo appeared like an angel from on high and fixed everything for me, getting my site back up and running in no time at all, with no fuss. Jo’s technical knowledge meant I could relay my problem in layman’s terms and she knew exactly what to do straight away. I would definitely recommend Jo Cox Design for anyone needing a website creating.

Frank Ralph