WordPress.org

Ready to get started?Download WordPress

Forums

Mon Cahier
How to make header image link to homepage (3 posts)

  1. TheSlenderStudent
    Member
    Posted 1 year ago #

    I'm having trouble editing the Mon Cahier theme to make my custom header image link back to my homepage. Any advice? Site is http://www.TheSlenderStudent.com

    http://wordpress.org/extend/themes/mon-cahier/

  2. Christine Rondeau
    WP Yogi & Forum Moderator
    Theme Author

    Posted 1 year ago #

    Hi there, I just took a look at your site and I like what you did. Unfortunately, the theme isn't coded so that the header image is linked to the home page. It's meant to have a title and description. However there is a way around that. It does take a bit of coding, but it's pretty easy.

    The first thing you'll want to do is make a child theme.

    Once you have a child theme, you should have a folder (call it mon-cahier-child or whatever you want). That folder will have a style.css with the following info in it.

    /*
    Theme Name: Mon Cahier Child
    Description: Child theme for the mon cahier theme
    Author: Your name here
    Template: mon-cahier
    */
    
    @import url("../mon-cahier/style.css");
    
    }

    Next you want to open the parent theme (mon-cahier) and copy the header. php. Bring that entire file in your child theme. Open it in a text-editor and on line #39, you can edit the line like so:

    <a href="http://www.theslenderstudent.com"><img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" /></a>

    That's it. Once you are done that, you might also want to install a plugin like WordPress SEO. Because you've removed the site title and description, your page titles now are not very informative. Just a thought..

    Good luck.

  3. radhika
    Member
    Posted 1 year ago #

    @TheSlenderStudent
    According your theme you have to delete some line in your header.php file such as:

    <?php $header_image = get_header_image();
    		if ( ! empty( $header_image ) ) { ?>
    
    			<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    
    		<?php } // if ( ! empty( $header_image ) ) ?>

    And add this code in your header.php file:

    <?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>
          <<?php echo $heading_tag; ?> id="site-title">
            <span>
              <a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
            </span>
          </<?php echo $heading_tag; ?>>

    After this, you have to edit in style.css of your theme:

    #site-title {
    float: left;
      padding: 10px 0;
      width: 960px;
    }
    #site-title a {
      color: #000;
      font-weight: bold;
      text-decoration: none;
      font-size: 180px !important;
      display: block;
      text-indent: -999em;
      background: url('image.jpg'); //path of your image
      height:200px;
    }

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic