How To Add A Clickable Custom Header Image

Seems there’s a lot of questions from problems caused when adding custom header images to different themes.

Part of the reason for this is that most people can work how to add a header image but not always make it link back to their homepage.

If you add your image url in your style.css file it won’t link back to your home page, so what to do?

Better to modify the PHP code which adds support for a custom header under your Appearance tab in your dashboard. This way you can use the custom header uploader which is coded in your functions.php file.

Lets take a look at using the Metro theme by StudioPress as one example in this tutorial.

We’ll be adding a header image which is 1080px X 150px

Child Themes Functions.php File

The default values in Metro on or about line 31 as follows:

add_theme_support( 'genesis-custom-header', array(
	'flex-height'	=> true,
	'height'		=> 87,
	'width'			=> 1080
) );

Simply change the height to 150.

add_theme_support( 'genesis-custom-header', array(
	'flex-height'	=> true,
	'height'		=> 150,
	'width'			=> 1080
) );

You’ll then find the header height values have changed when you go to Appearance > Header > Custom Header.

Default Custom Header Size

default custom header size

New Custom Header Size

new custom header size

You’ll also need to change the height values in your style sheet.

Child Themes Style.css File

Next, open up your child theme style.css file and find the CSS code which targets your header.

The defaults values for the height on line 516 are as follows:

#header {
	min-height: 87px;
	overflow: hidden;
}

And also the height value on line 558 which needs to be changed is:

.header-image #title,
.header-image #title a,
.header-image #title-area {
	display: block;
	float: left;
	min-height: 87px;
	overflow: hidden;
	text-indent: -9999px;
}

So change both these height values so the code looks like this:

#header {
	min-height: 150px;
	overflow: hidden;
}

And also the height value on line 558 which needs to be changed is:

.header-image #title,
.header-image #title a,
.header-image #title-area {
	display: block;
	float: left;
	min-height: 150px;
	overflow: hidden;
	text-indent: -9999px;
}

Using the custom header uploader to upload your image, which is added when you add support for a custom header page in your functions.php file, ensures your header image will link back to your home page when clicked.

More Display Options For Custom Header Images

You can still use the header right widget area however it will output your content in your header which may or may not display in your image.

If you have a logo which is smaller, you could create a new canvas using a web design tool like Paint.net for Windows or GIMP for Mac which is the same size as the dimensions you customized above and add your logo to a white or transparent background.

Adding header images and logos using CSS generally causes problems and won’t link back to your home page unless you know how to add a link to the code.

Note: Some themes include a flexible height in the CSS code meaning you don’t always need to modify the CSS to the size of your custom header image.

You may also some across some themes like Eleven40 which the above methods won’t work as there’s more involved when changing to a custom header image with themes like this.

Learn more about changing header sizes in different WordPress themes.

You can also display custom header images on different pages like your home page and category archives pages as well.


Comments

4 responses to “How To Add A Clickable Custom Header Image”

  1. Brad, I’ve been all over your sites today! Seemed every time I Googled something the right answer led me here.

    I’m developing a new site and had to do some major playing around with media queries. I have everything the way I want now, but to achieve it I had to create a special sized header image for smartphones. The problem is my header image is no longer served through the uploader, I’ve added it via css. Now I don’t have a clickable header. I know how to fix that on a non Genesis site where I know what’s going on in the header.php but that’s not the case here.

    As you said above “Adding header images and logos using CSS generally causes problems and won’t link back to your home page unless you know how to add a link to the code.” So true! So please, could you tell me what to do to attain a clickable link to a header image I have inserted via css?

    Thanks for all the helpful tutes!

    1. Brad Dalton Avatar
      Brad Dalton

      Hello Elle

      You’ll need to write a custom function using PHP code to make it clickable.

      This can’t be done with CSS on its own.

  2. Brad,

    Your tutorials are always so helpful, well-written, and easy to follow.

    Is there a way to do both? Keep the header text and byline and put a clickable logo in the header? Have you found a way by editing the functions file or using jquery?

    Thanks!

    1. Brad Dalton Avatar
      Brad Dalton

      Hello Jason

      Thanks for the kind words.

      I wouldn’t use Javascript for it but yes. I published a tutorial yesterday on how to add an image next to a text title which should help.

Leave a Reply

Join 5000+ Followers

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