Change Header Image Link To Any URL

Be default, most themes will be coded to link your logo or header image to your home url.

In this post, i’ll provide several solutions you can use to change the url your header image is linked to depending on which theme you’re using.

Because of the way themes are coded differently, there’s no one solution which works on all themes.

Genesis Child Themes

Simply copy this code from the view raw link in the Gist and paste it at the end of your child themes functions.php file, then change the URL in the code to suit your own needs.

Source: StudioPress Members Code Snippets

Twenty Twelve Default Theme

You’ll need to copy over the parent themes header.php file to a child theme and modify the code as follows.

Line 49, change this part of the code:

<a href="<?php echo esc_url( home_url( '/' ) ); ?>">

To this:

<a href="http://example.com/">

Twenty Thirteen Default Theme

You’ll need to copy over the parent themes header.php file to a child theme and modify the code as follows.

Line 36, change this part of the code:

&lt;a class="home-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="

To this:

&lt;a class="home-link" href="http://example.com/" title="

Twenty Fourteen Default Theme

You’ll need to copy over the parent themes header.php file to a child theme and modify the code as follows.

Line 37, change this part of the code:

<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">

To this:

<a href="http://example.com/" rel="home">

Not very elegant compared to what Genesis offers using the filter.

I’m sure there must be a filter that can be used with non Genesis themes to change the URL a logo or full width header image links to.

Other Options

Update:Kat asked a really good question in the comments about removing the Site Title so here’s a few more options you may find useful.

Remove Site Title

You can easily remove the site title using CSS or simply remove the text from your General Settings > Site Title.

.site-title {
display: none;
}

Remove Header & Add Custom Header

Another option you might like is to remove the default genesis_header and add your own like this:

Step 1. Add this code to your child themes functions.php file to remove the default header:

remove_action( 'genesis_header', 'genesis_do_header' );

Or you could also remove the markup as well but in most cases, best to leave it and modify the default Site Header CSS rules to match your header.

//* Remove site header markup
remove_action( 'genesis_header', 'genesis_header_markup_open', 5 );
remove_action( 'genesis_header', 'genesis_header_markup_close', 15 );

This option removes all the classes added to the header so all the CSS in your style sheet for different Site Header markup no longer works.

Step 2. Add this PHP to your functions file and change the path to your images folder to match your image file name and extension.


Comments

5 responses to “Change Header Image Link To Any URL”

  1. I tried the code for Genesis child themes (I’m using Epik) and it added in the text blog name along with my logo in the header. The text title had the new link I added, not the logo. Any idea how to modify the code to just link to the logo, and not show the title? Thanks. I asked this on the Studiopress and Appfinite forums and got no response.

    1. Brad Dalton Avatar
      Brad Dalton

      Have you tried removing the Site Title from the General settings?

      You’re right. The code modifies the title link and not the image because of the way it has been added.

      You could add the header image using PHP and include a custom link URL that way. Please see the Other Options i added near the end of the post.

  2. Keith Davis Avatar
    Keith Davis

    Worth knowing Brad.
    I’m so glad you are a Genesis man.

    I don’t know if you visit the StudioPress blog very often, but things are rather slow over there.
    No action for a month.

    1. Brad Dalton Avatar
      Brad Dalton

      Yeah saw that Keith. Must be busy working on something.

      1. Keith Davis Avatar
        Keith Davis

        Never thought of that… let’s hope so.

Leave a Reply

Join 5000+ Followers

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