26 | Link Header Image to Home Page

g+

Having the whole header image linking to the home page is one of the most common things of a theme. This article explains how to add this feature to the WordPress theme Twenty Ten.

Edits are to be made in header.php of a child theme of Twenty Ten, at the location recognizable below (theme version 1.6):

<div id="site-description"><?php bloginfo( 'description' ); ?></div>
<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
<?php
// Compatibility with versions of WordPress prior to 3.4.
if ( function_exists( 'get_custom_header' ) ) {
.....
.....
<img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />
 <?php endif; ?>
</a></div><!-- #branding -->

The link tag

<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">

was added just after this line

<div id="site-description"><?php bloginfo( 'description' ); ?></div>

and closed it before the end of the #branding div

</a></div><!-- #branding -->

that is all.

This entry was posted in Easy Coding for Wordpress, WordPress and tagged , , , . Bookmark the permalink.

46 Responses to Link Header Image to Home Page

  1. Alex Hennemann comments:

    Hey on my home page the header doesn t work. on every other page it works and just if i change homepage to another site it won t work too.

  2. Codi Pellerin comments:

    Hey on my home page the header doesn t work. on every other page it works and just if i change homepage to another site it won t work too.

  3. Sheena comments:

    Hi there it’s me, I am also visiting this website daily, this web
    site is actually good and what’s the tallest building in the world (Adrianna)
    users are in fact sharing good thoughts.

  4. Damaris comments:

    Your means of explaining what’s the tallest
    building in the world (http://www.firefars.com) whole
    thing in this paragraph is truly nice, all can effortlessly be aware of it, Thanks a
    lot.

  5. Hugh comments:

    I don’t even know tallest building in the us way I finished up right here, however
    I thought this publish used to be great. I do not
    recognise who you are however definitely you are going to a famous blogger should you aren’t already.
    Cheers!

  6. Harrison comments:

    Every weekend i used to pay a visit this website, because i wish for enjoyment, for what’s
    the tallest building in the world (Cefas.cnrs.fr)
    reason that this this web site conations actually nice funny material too.

  7. Heike comments:

    Thanks in favor of sharing such o m a nice opinion, paragraph is
    pleasant, thats why i have read it completely

  8. Cliff comments:

    Hello would you mind sharing which blog platform you’re working with?
    I’m looking to start my own blog in the near
    future but I’m having a hard time selecting between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask where is the tallest building in the world because your design seems different
    then most blogs and I’m looking for something completely unique.
    P.S Sorry for getting off-topic but I had to ask!

  9. Lavada comments:

    An outstanding share! I have just forwarded this onto a colleague who
    has been doing a little homework on this. And he actually bought me lunch because I found
    it for him… lol. So allow me to reword this…. Thanks for tallest building in the us meal!!
    But yeah, thanx for spending time to talk about this subject here on your blog.

  10. Ethel comments:

    Peculiar article, just what I wanted to find.

    My site worlds tallest building

  11. Theodore comments:

    Yes! Finally something about lexus hoverboard (http://Www.Arch2O.com) in action.

  12. Ofelia comments:

    This typography design is
    incredible! You obviously know how to keep a reader entertained.
    Between your wit and your videos, I was almost moved to start
    my own blog (well, almost…HaHa!) Great job. I really loved what you had to say, and more
    than that, how you presented it. Too cool!

  13. Tegan comments:

    Having read this I thought it was very enlightening.
    I appreciate you finding the kingdom tower time
    and effort to put this short article together. I once again find myself
    spending a lot of time both reading and commenting.

    But so what, it was still worth it!

  14. Tiffiny comments:

    It where is the tallest building in the world really a great and useful
    piece of info. I am glad that you shared this useful information with us.
    Please keep us informed like this. Thank you
    for sharing.

  15. Swen comments:

    I do not know if it’s just me or if perhaps everyone else encountering
    issues with your site. It appears as if some of best architecture schools in the us text within your posts are running off the screen. Can someone else please comment and let
    me know if this is happening to them too? This could
    be a problem with my internet browser because I’ve had this happen before.
    Thanks

  16. Peter comments:

    When I originally commented I seem to have clicked on the
    -Notify me when new comments are added-
    checkbox and from now on each time a comment what is the tallest building in the world
    added I recieve four emails with the exact same comment.
    There has to be an easy method you are able to remove me from that service?
    Appreciate it!

  17. Gwen comments:

    Hi there friends, how is all, and what you would like to say about this
    piece of writing, top architecture schools in us
    my view its really amazing in favor of me.

  18. Gerald comments:

    I blog often and I truly appreciate your information.
    Your article has truly peaked my interest. I’m going to take a note of your site
    and keep checking for new details about once a week. I subscribed to your RSS
    feed as well.

    My blog post bill gates house inside

  19. Winona comments:

    Very good blog post. I absolutely love this website. Continue what’s the tallest building in the world good work!

  20. Evans Tang comments:

    This is great! Thanks for providing a simple solution that works perfectly

  21. NE comments:

    It’s slightly different in the latest version of the theme…

    Now the <a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
    code will go above the following
    <?php
    // Compatibility with versions of WordPress prior to 3.4.
    if ( function_exists( 'get_custom_header' ) ) {
    // We need to figure out what the minimum width should be for our featured image.
    // This result would be the suggested width if the theme were to implement flexible widths.
    $header_image_width = get_theme_support( 'custom-header', 'width' );
    } else {
    $header_image_width = HEADER_IMAGE_WIDTH;
    }

  22. Tiana Kai comments:

    THANK YOU!!

  23. glissy comments:

    Thanks, just what I was looking for!!

  24. Steve comments:

    Thanks a million. This solved my problem perfectly!

  25. RobertNAdams comments:

    You would not believe the stuff I went through last night trying to get this to work on my buddy’s WordPress site. I tinkered with .php files. I looked for plugins. I was ready to commit seppuku with a rusty butter knife.

    I never thought to just wrap a hyperlink around the php. How stupid of me! Thanks, this was super helpful (even in a non-2010 theme)!

  26. Leah comments:

    Thank you! Worked perfectly. 🙂

  27. Salman comments:

    I want to replace my WordPress twenty ten. Header with an Image Map.
    When I convert the Actual header to an image map in CS Adobe Photoshop, I get an html image map code and my actual header image broken into 4 different jpeg files, each showing the area where I want a differnt link.

    Now please guide me as to where should I Insert this Image map code, which header file, and do I simply upload the 4 images to my media foler, and update the image source links in the image map code, which I have to insert ???
    or the Image map code will work with my full size header image as well.

  28. Christian from Sweden comments:

    Well, that was a nice fix! Thanks a bunch, mr alchymyth 🙂
    Took 30 seconds to implement, and with desired result.

  29. maryam comments:

    Hi Alchymyth, thanks a lot for sharing this. Ihave several images on my header and all link to different urls and it works well, my line in header is:

    <img src="my image” alt=”” />

    what I need to do next is (hover) when mouse on the image, image change to a different image!
    any idea!?

    Thanks
    Maryam

  30. Tim comments:

    Great tip for someone who isn’t that familiar with php. Thank you. I’ve now been asked if we can link back to our website URL via the header instead of the blog homepage. Is there a way to change the link to an external ‘http://www.mysite.com’ link?

    • alchymyth replies:

      Hi Tim,

      this is the actual part with the link url:
      <a href="<?php echo home_url( '/' ); ?>"
      change it to:
      <a href="http://mysite.com"

      if you have more questions regarding wordpress, consider joining http://wordpress.org/support/

      • Les replies:

        I knew this must be possible, I have searched high and low to find an answer to linking the header image to a page outside of the WordPress directory. I had identified where and which bit of the link needed to be edited, but to what??? (I am no php guru).
        This is a fantastic tip, thank you for sharing it Mr Alchymth.

      • alchymyth replies:

        example:
        <a href=\"http://www.outsidepage.com\" title="link to outside page" rel="home" rel="nofollow">

        I needed to add \ to get the code to show – remove the two backslash \

  31. Robotnyheter comments:

    Thanks for the tip!

    I added the modified header.php to my TwentyTen child theme (so it’s still there when the theme is updated) and also removed the “title” parameter as I don’t want the tooltip text when hovering the mouse over the header image. So this is the code I added:


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

    • Michael replies:

      Hej,
      utmärkt tips!
      I inserted the code in the header.php of my twentyten child and it works great for the whole blog (including post and page header images linking back to the home blog).

      Also, I deleted the title attribute. However, when mousing over the header images of posts or pages, the title is still displayed. Have you got any idea why that is? I didn’t get any answers in the wordpress forum…

      Thanks for your help!

  32. dowel comments:

    Thank you very much. I translated this into German to spread the news and – of course – linked back to your tipp.

  33. Dallas Divorce comments:

    Thank you so much! I felt so dense without knowing how to do this… after reading four or five other blogs about turning the header into a link, yours finally solved my issue. Thank you for making it so clear, too.

    Dallas Divorce

  34. Li comments:

    Thanks a lot for the hint of doing it.

    Does this manipulation make a future upgrade impossible?

  35. DUI Facts comments:

    Thanks, that works great, appreciate the help.

  36. bob comments:

    Thanks. I needed exactly what you have done. I am a retired person, taking web programming courses at a local tech college, and we are using WordPress to build a site for a non-profit organization.

    Now, I have to psyche out what is going on with the PHP stuff. Gotta get into the API.

    Once again, thanks.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.