How do I make simplemarket header image a link?

Really simple fix I'm sure, but I am a beginner...

How do I make simplemarket header image a link? (back to the store homepage)

  • Dharmendra

    Hi Ethan,

    I hope you are doing well!

    To achieve this you will need to edit the header.php file.

    For this you can use a child theme as described here
    https://premium.wpmudev.org/manuals/what-are-parent-and-child-themes/ to upgrade-safe edit.

    With that, you can copy the header.php from the main theme here into your newly created child theme, then edit that header.php as needed.

    You will need to edit the line no. 65 as mentioned below:
    <a href="<?php get_site_url(); ?>"><img src="<?php echo $simpleheader; ?>" class="header-image" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" /></a>

    This is will add the homepage link to the header image.

    Please have a try and let me know if you face any issue.

  • Patrick

    Hey there @Ethan

    Welcome to the forums, glad to have you aboard!

    Before making such an edit, I would highly recommend you first make a child-theme so you don't have to re-do these edits when you update the theme.

    If you've never made a child-theme before, here's a simple tutorial to get you going:
    https://premium.wpmudev.org/blog/create-wordpress-child-theme/

    Once you have your child-theme, copy the header.php file from SimpleMarket to your child-theme and scroll down to where you see the following:

    <div id="header-image">
    <img src="<?php echo $simpleheader; ?>" class="header-image" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    </div>

    All you need to do is wrap the image code in the HTML you need to make it a link, so it becomes this:

    <div id="header-image">
    <a href="http://your-site-here"><img src="<?php echo $simpleheader; ?>" class="header-image" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" /></a>
    </div>

    Change http://your-site-here to whatever address you want. Then save that file and upload your child-theme to your site. You can then activate your child-theme and your header will now link to whatever you entered.

  • Ethan

    Now the text below my header has all become linked text. How do I stop the text from being linked with the header?

    http://www.dakhota.org/store

    <?php
    /**
    * Header
    *
    * @package SimpleMarket
    * @subpackage Template
    * @since SimpleMarket 1.0
    */
    ?>
    <!DOCTYPE html>
    <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
    <!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
    <!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
    <!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
    <!--[if (gt IE 9)|!(IE)]><!--> <html <?php language_attributes(); ?> class="no-js"> <!--<![endif]-->
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>
    <?php global $page, $paged;
    wp_title( '|', true, 'right' );
    bloginfo( 'name' );
    $site_description = get_bloginfo( 'description', 'display' );
    if ( $site_description && ( is_home() || is_front_page() ) )
    echo " | $site_description";
    if ( $paged >= 2 || $page >= 2 )
    echo ' | ' . sprintf( __( 'Page %s', TEMPLATE_DOMAIN), max( $paged, $page ) );
    ?>
    </title>
    <link rel="profile" target="_blank" href="http://gmpg.org/xfn/11">
    <link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url') ?>" type="text/css" media="screen" />
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    <?php wp_head(); ?>
    </head>
    <body <?php body_class() ?>>
    <div id="site-wrapper">
    <div id="site-outer">
    <nav id="top-nav" role="navigation">
    <div id="nav-inner">
    <?php wp_nav_menu( array(
    'theme_location' => 'top_menu',
    'menu_class' => 'topmenu',
    'container' => '',
    'fallback_cb' => 'simplemarket_fallback_menu'
    )); ?>
    <div class="clear"></div>
    </div>
    </nav>
    <div id="site-inner">
    <header id="branding" role="banner">
    <div id="branding-inner">
    <div id="site-logo">

    </div>
    <div id="site-actions">
    <div id="site-description"><?php bloginfo('description'); ?> </div>
    <div id="search-box"> <?php get_search_form(); ?></div>
    </div>
    </div>
    <?php
    $simpleheader = get_header_image();
    if ($simpleheader != ""){
    ?>
    <div id="header-image">
    <img src="<?php echo $simpleheader; ?>" class="header-image" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    </div>
    <?php } ?>
    </header>
    <div id="main">
    <div id="main-inner">

  • Michael Bissett

    Hey @Ethan,

    I'm not able to determine what's going on from the code you posted here, I'm going to have to look at the header.php you set up. Could you send in the following:

    - A link back to this thread
    - Include admin/network access
    - Include cPanel (I will need to look at the DB so need PHPMyAdmin or similar)
    - Include FTP
    - Include any relevant URLs for your site
    - Ensure that it's marked to my attention - ATTN: Michael Bissett

    On the contact form, select "I have a different question", this ensures it comes through and gets assigned to me.

    https://premium.wpmudev.org/contact/

    Thanks! :slight_smile:

    Regards,
    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.