• Resolved Morgan1er

    (@morgan1er)


    Hi,
    I’m having problems adding a link to the header image to get back to the homepage.
    Here is the code I have in my header.php:

    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><header id="masthead" class="site-header" role="banner" <?php if ( ! empty( $header_image ) ) { ?>style="background:url(<?php header_image(); ?>) no-repeat center center; background-size: cover; height:<?php echo get_custom_header()->height; ?>px;" <?php } ?>>
    		<hgroup>
    			<div class="site-text">
    				<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>
    				<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
    			</div>
    		</hgroup>
    	</header></a><!-- #masthead .site-header -->

    Any idea why it does not work? And how to make it work of course ??
    Thx in advance for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Morgan1er

    (@morgan1er)

    And here is my site: https://gladysworks.com/wordpress/

    Thread Starter Morgan1er

    (@morgan1er)

    Wow, just made it!
    I was looking around on the web and i found help in the wordpress codex.

    So I used an onclick attribute and it works:

    <header id=”masthead” class=”site-header” role=”banner” <?php if ( ! empty( $header_image ) ) { ?>style=”background:url(<?php header_image(); ?>) no-repeat center center; background-size: cover; height:<?php echo get_custom_header()->height; ?>px;” <?php } ?> onclick=”location.href='<?php echo esc_url( home_url( ‘/’ ) ); ?>’;” style=”cursor: pointer;” title=”<?php echo esc_attr( get_bloginfo( ‘name’, ‘display’ ) ); ?>” rel=”home”>

    Hope it helps.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Link on header image’ is closed to new replies.