• Hi, I would like to have the header redirect to the home page from anywhere on the website. I have been trying everything written on the forums, including inserting a “a href…” tag in the custom header.php, which shut the whole site down, including the admin platform (HTTP 500). It seems like a pretty basic feature, still I can’t manage it anyhow…

    Any ideas (which don’t make my site collapse again)?

    My site is rhbaba.hu, and I use the Sela theme.

    Thanks!

Viewing 1 replies (of 1 total)
  • Hi @maszatjanka!

    Definitely doable 🙂 We’ll want to remove the current text link, since that one will be effectively replaced by the new link you’re adding. First, make sure you have a child theme ready to work in so these changes are safe during future theme updates.

    Next, make a copy of the parent theme’s header.php file in your child theme folder.

    In that file, you’ll see a line like this:

    <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>

    That creates a link to the home page of the site, using the site title. We’ll need to trim that down a bit to just this:

    <h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>

    Now we’re displaying the title, but not as a link.

    Next, we add our own link! A few lines up from where were just working you’ll see the beginning of the .site-branding block:

    <div class="site-branding">

    Add a new line just below that. On that line, paste the following:

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

    This recreates the original link, but as an empty box instead of text. We’ll use CSS to give it the size, shape, and position it needs:

    
    .site-branding {
        position: relative;
    }
    
    .header-link {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 1;
    }

    That should do the trick! Let me know how it goes

Viewing 1 replies (of 1 total)

The topic ‘Making header image clickable’ is closed to new replies.