- This topic has 9 replies, 2 voices, and was last updated 10 years, 9 months ago by tim6007.
-
AuthorPosts
-
February 22, 2014 at 8:21 pm #20627tim6007Member
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 🙂February 23, 2014 at 1:09 am #20634SakinKeymaster@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 }
February 23, 2014 at 2:25 am #20640tim6007MemberHi 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.
February 23, 2014 at 3:12 am #20643tim6007MemberHi 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 imageAs 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?
February 23, 2014 at 9:28 am #20647SakinKeymaster@tim6007: I think you missed the closing bracket
}
. Please check the code with the above mentioned code.February 23, 2014 at 7:13 pm #20664tim6007MemberThanks 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
especially this part … ( home_url( ‘/’ ) )
I have tried deleting that but it just breaks the theme, so I must be missing something.
Any ideas?
February 23, 2014 at 8:39 pm #20667SakinKeymaster@tim6007: After you create child theme, you need to reassign header image from “Appearance => Header”
February 23, 2014 at 10:44 pm #20674tim6007MemberLol, 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”>
</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
February 23, 2014 at 11:43 pm #20676SakinKeymaster@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 }
February 24, 2014 at 3:10 am #20680tim6007MemberBingo!
That’s done the trick thanks Sakin.
-
AuthorPosts
- The topic ‘How To Disable The Header Image Link?’ is closed to new replies.