Filter Custom Header Images Conditionally

This filter hook enables you to modify the output of your custom header and use conditional tags if needed.

It works with any theme however relies on your theme including support for a custom header.

1Check For Custom Header Support

Check your child themes functions file for code which looks like this:

If your theme doesn’t already include the above code, add it to your child themes functions.php file and change the values to match your header image width and height.

2Add Code To Functions File

Copy this code from the view raw link in the Gist and paste it at the end of your child themes functions.php file.

This code changes the header images on pages with the slug example-one and example-two which you can modify to your own. The images are pulled from your child themes images folder and the file names and extensions need to match what’s in the code.

3Modify Additional Header Elements

If your theme includes and you are using a header widget or other header features, you will need to modify your code so your custom header image isn’t cut off when using a full width image.

If your theme doesn’t include any other header features or your header image is less than full width you generally won’t need to make any modifications to any header CSS.

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.