Tagged: ,

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #20627
    tim6007
    Member

    Hi guys,

    This is a great theme and perfect for what I want, with just one exception.

    Please can you tell me how to disable the header image link?

    I need to use a custom header but it must NOT link to the home page.

    I have ripped the internet apart looking for a way to do this in WP, it seems everyone just wants to add this link, and nobody on the planet except me wants to remove it.

    I have tried to remove a few snippets myself but only succeeded in breaking the theme.
    I am not a coder, so any help on how to do this in a simplified fashion would be much appreciated.

    P.S.
    Has anyone noticed how fast this theme loads right out the box? It’s a beauty 🙂

    #20634
    Sakin
    Keymaster

    @tim6007: Thanks for your appreciation and to remove the link from custom header. First you need to build child theme. Then you need to create functions.php file in your child theme and add the following code.

    <?php 
    /**
     * Template for Header Image
     *
     * To override this in a child theme
     * simply create your own catchbox_header_image(), and that function will be used instead.
     *
     * @since Catch Box 2.5
     */
    function catchbox_header_image() {
    	
    	// Check to see if the header image has been removed
    	global $_wp_default_headers;
    	$header_image = get_header_image();
    	if ( ! empty( $header_image ) ) : ?>
        
        	<div id="site-logo">
            	<a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
                    <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" />
                </a>
          	</div>
            
    	<?php endif; // end check for removed header image 	
    }
    #20640
    tim6007
    Member

    Hi Sakin,

    Thanks for your very prompt response, much appreciated.

    I had a feeling it was something to do with the functions file.
    Fortunately I already know how to add a child theme, and it did have it on the backburner for this project looks like I will have to do it now.

    I’ll give that code a go thanks.

    #20643
    tim6007
    Member

    Hi Sakin,

    I just tried that code and got an error

    Parse error: syntax error, unexpected $end in /themes/catchbox-child-theme/functions.php on line 23

    That’s this line below…
    <?php endif; // end check for removed header image

    As I’m not a coder I have no idea what this means, but I just want to say again in case I wasn’t clear, I don’t want to remove the header image only the internal code link from the header image to the home page.

    I only used that snippet in the functions.php child file and left the parent functions as it was, this is correct yes?

    Any ideas or corrections please?

    #20647
    Sakin
    Keymaster

    @tim6007: I think you missed the closing bracket } . Please check the code with the above mentioned code.

    #20664
    tim6007
    Member

    Thanks Sakin and yes, I did miss the bracket child theme now works.

    This code however removes the whole header image, but the link is still active.

    I want to show the header image but break the link to the home page.

    Something tells me it is to do with this line…. Line 315 functions php

    <h1> onclick=”return false;” href=”<?php echo esc_url( home_url( ‘/’ ) ); ?>”><?php bloginfo( ‘name’ ); ?></h1>

    especially this part … ( home_url( ‘/’ ) )

    I have tried deleting that but it just breaks the theme, so I must be missing something.

    Any ideas?

    #20667
    Sakin
    Keymaster

    @tim6007: After you create child theme, you need to reassign header image from “Appearance => Header”

    #20674
    tim6007
    Member

    Lol, yes I remembered I needed to do that after posting the reply, I have the header back but the home link still remains.

    I will have one last try at resolving this.

    Here is what I believe is the offending code as it appears in the browser source code

    \
    <div id=”page” class=”hfeed”>
    <header id=”branding” role=”banner”>

    <div id=”header-content” class=”clearfix”>

    <div class=”logo-wrap clearfix”>
    <div id=”site-logo”>

    xxxx.com

    </div>

    <div id=”hgroup” class=”site-details with-logo”>
    <h1 id=”site-title”>xxxxx.com</h1>
    <h2 id=”site-description”></h2>
    </div><!– #hgroup –>

    </div><!– .logo-wrap –>
    \

    But this does not appear in the header.php or anywhere else I can see

    #20676
    Sakin
    Keymaster

    @tim6007: I just showed you the code. There you need to remove the link. If you want to remove link then replace previous code with the following

    <?php 
    /**
     * Template for Header Image
     *
     * To override this in a child theme
     * simply create your own catchbox_header_image(), and that function will be used instead.
     *
     * @since Catch Box 2.5
     */
    function catchbox_header_image() {
    	
    	// Check to see if the header image has been removed
    	global $_wp_default_headers;
    	$header_image = get_header_image();
    	if ( ! empty( $header_image ) ) : ?>
        
        	<div id="site-logo">
            	<img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" />
          	</div>
            
    	<?php endif; // end check for removed header image 	
    }
    #20680
    tim6007
    Member

    Bingo!

    That’s done the trick thanks Sakin.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘How To Disable The Header Image Link?’ is closed to new replies.