- This topic has 14 replies, 2 voices, and was last updated 12 years, 7 months ago by Sakin. 
- 
		AuthorPosts
- 
		
			
				
March 7, 2013 at 8:34 am #4747Robertf ParticipantHi, I want to customise Catch Box Pro to display the H1 tag for the Site Title only on the Home page. I think I know how to do this, but I cannot find the catchbox_before_headercontent() function that I suspect contains the Site Title & Description code. Can you please tell me where I can find this function? Regards, Robertf March 8, 2013 at 1:04 am #4773Sakin KeymasterIt’s in the function catchbox_headerdetails() in custom-header.php. You need to build child theme and then you can just remove the action by adding the following code in functions.php in your child theme. 
 remove_action( 'catchbox_headercontent', 'catchbox_headerdetails', 11 );Then build your function with changes such as catchbox_headerdetails_child() and hook with action hook 
 add_action( 'catchbox_headercontent', 'catchbox_headerdetails_child', 12 );March 9, 2013 at 3:33 am #4843Robertf ParticipantThanks, Sakin. Will try your suggestion and let you know how it works. Regards, Robertf March 11, 2013 at 9:21 am #4948Robertf ParticipantHi Sakin, I tried your code suggestion, but the results is that the header is displayed twice, as per the source code extract: 
 <div id=”header-content” class=”clearfix“>
 <div class=”logo-wrap clearfix“>
 <div id=”site-logo“><a href=”http://192.168.0.192/wordpress/” title=”RobertFairhead.com” rel=”home“>
 <img src=”http://192.168.0.192/wordpress/wp-content/uploads/cropped-head-robert-bw-sm22.png” width=”103” height=”140” alt=”RobertFairhead.com” />
 </a></div>
 <hgroup id=”site-details“>
 <h1 id=”site-title“><a href=”http://192.168.0.192/wordpress/” title=”RobertFairhead.com” rel=”home“>RobertFairhead.com</a></h1>
 <h2 id=”site-description“>The Tall and True Tales of a Midlife Man</h2>
 </hgroup>
 </div><!– .logo-wrap –>
 <div class=”logo-wrap clearfix“>
 <div id=”site-logo“><a href=”http://192.168.0.192/wordpress/” title=”RobertFairhead.com” rel=”home“>
 <img src=”http://192.168.0.192/wordpress/wp-content/uploads/cropped-head-robert-bw-sm22.png” width=”103” height=”140” alt=”RobertFairhead.com” />
 </a></div>
 <hgroup id=”site-details“>
 <h1 id=”site-title“><a href=”http://192.168.0.192/wordpress/” title=”RobertFairhead.com” rel=”home“>RobertFairhead.com</a></h1>
 <h2 id=”site-description“>The Tall and True Tales of a Midlife Man</h2>
 </hgroup>
 </div><!– .logo-wrap –>
 <div id=”sidebar-header-right” class=”widget-area sidebar-top clearfix“>
 <aside id=”quotescollection” class=”widget quotescollection_widget“><div id=”quotescollection_randomquote-0” class=”quotescollection_randomquote“><p><q>A day without laughter is a day wasted.</q> <cite>— <span class=”quotescollection_author“>Charlie Chaplin</span></cite></p><script type=”text/javascript“>quotescollection_timer(0, 2, 1, 1, ”, 500, 60, 1);</script></div></aside><aside id=”search-3” class=”widget widget_search“> <form method=”get” id=”searchform” action=”http://192.168.0.192/wordpress/“>
 <label for=”s” class=”assistive-text“>Search</label>
 <input type=”text” class=”field” name=”s” id=”s” placeholder=”Search” />
 <input type=”submit” class=”submit” name=”submit” id=”searchsubmit” value=”Search” />
 </form>
 </aside></div> <!– #sidebar-top –>
 </div><!– #header-content –>
 I researched what may be causing this and found 2 possible problems:1) The priority of the remove_action needs to match the priority used in the add_action. Therefore, I modified your suggested code as follows, but this had no effect: remove_action( ‘catchbox_headercontent’, ‘catchbox_headerdetails’, 15 ); 2) The remove_action can be done only after the action is added. I wondered if this is the problem, if the Catch Box Pro add_action( ‘catchbox_headercontent’, ‘catchbox_headerdetails’, 15 ) is not called till after my remove_action( ‘catchbox_headercontent’, ‘catchbox_headerdetails’, 15 )? BTW: I have put the your suggested code fix and my modified catchbox_headerdetails_child() in functions.php in my Child Theme. I hope this is enough to help you to work out what I’m doing wrong. Regards, Robertf March 11, 2013 at 9:39 am #4950March 11, 2013 at 11:42 am #4959Robertf ParticipantHi Sakin, The following is a copy of functions.php from my Child Theme: Regards, Robertf <?php /** * Child Theme overrides for Catch Box Pro functions and definitions * * When using a child theme (see http://codex.wordpress.org/Theme_Development and * http://codex.wordpress.org/Child_Themes), you can override certain functions * (those wrapped in a function_exists() call) by defining them first in your child theme’s * functions.php file. The child theme’s functions.php file is included before the parent * theme’s file, so the child theme functions would be used. * * Functions that are not pluggable (not wrapped in function_exists()) are instead attached * to a filter or action hook. The hook can be removed by using remove_action() or * remove_filter() and you can attach your own function to the hook. * * We can remove the parent theme’s hook only after it is attached, which means we need to * wait until setting up the child theme: * * <code> * add_action( ‘after_setup_theme’, ‘my_child_theme_setup’ ); * function my_child_theme_setup() { * // We are providing our own filter for excerpt_length (or using the unfiltered value) * remove_filter( ‘excerpt_length’, ‘catchbox_excerpt_length’ ); * … * } * </code> * * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API. * * @package Catch Themes * @subpackage Catch_Box_Pro * @since Catch Box Pro 1.0 */ /** * Stop H1 tags from being set for Site Title on all pages: * * Header Details including Site Logo, Title and Description * * @Hooked in catchbox_headercontent in Catch Box Pro functions.php. * @since Catch Box 1.2.1 * */ remove_action( ‘catchbox_headercontent’, ‘catchbox_headerdetails’, 15 ); /** *add_action( ‘catchbox_headercontent’, ‘catchbox_headerdetails_child’, 12 ); */ function catchbox_headerdetails_child() { ?> <div class=”logo-wrap clearfix”> <?php // Check to see if the header image has been removed $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 ?> <hgroup id=”site-details”> <h1 id=”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 id=”site-description”><?php bloginfo( ‘description’ ); ?></h2> </hgroup> </div><!– .logo-wrap –> <?php } /** * Don’t print Author details & link for single author blog, so modify following code used in content.php etc: * printf( __( ‘<span class=”sep”>Posted on </span><a href=”%1$s” title=”%2$s” rel=”bookmark”><time class=”entry-date updated” datetime=”%3$s” pubdate>%4$s</time></a><span class=”by-author”> <span class=”sep”> by </span> <span class=”author vcard”><a class=”url fn n” href=”%5$s” title=”%6$s” rel=”author”>%7$s</a></span></span>’, ‘catchbox’ ), */ function catchbox_posted_on() { printf( __( ‘<span class=”sep”>Posted on </span><a href=”%1$s” title=”%2$s” rel=”bookmark”><time class=”entry-date updated” datetime=”%3$s” pubdate>%4$s</time></a></span></span>’, ‘catchbox’ ), esc_url( get_permalink() ), esc_attr( get_the_time() ), esc_attr( get_the_date( ‘c’ ) ), esc_html( get_the_date() ), esc_url( get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ), esc_attr( sprintf( __( ‘View all posts by %s’, ‘catchbox’ ), get_the_author() ) ), get_the_author() ); } March 11, 2013 at 11:44 am #4960Robertf ParticipantPS. Sorry, Sakin, I’ve just notice that I’d commented out the add_action( ‘catchbox_headercontent’, ‘catchbox_headerdetails_child’, 12 ); This was just so I could get on with testing, until I worked out how to do use the Child Theme function without displaying the double Header. Regards, Robert March 11, 2013 at 5:59 pm #4970Sakin Keymaster@Robertf: Is it working. I have emailed you so that you can send me code. This forum is quite complicated for codes. Sorry for that. March 12, 2013 at 8:13 am #4996Robertf ParticipantHi Sakin, No, unfortunately the Child Theme remove/add_action is still resulting in 2 headers being displayed. I have emailed you a zipped copy of my Catch Box Pro & Child Theme folders. I do appreciate that it’s hard to work through the code on the forum & trust that the zip copy helps. Once again, thanks for your assistance. Regards, Robertf March 12, 2013 at 11:13 am #5011Sakin KeymasterHi Robert, Sorry, I gave you wrong action to remove it. I didn’t realize it was for the child theme. First you have to Unhook default Catch Box Pro functions by adding following functions in your child theme functions. 
 // Unhook default Catch Box Pro functions
 function unhook_catchbox_functions() {
 // Don’t forget the position number if the original function has one
 remove_action( ‘catchbox_headercontent’, ‘catchbox_headerdetails’, 15 );
 }
 add_action( ‘init’, ‘unhook_catchbox_functions’ );Then you can add in your own function like below: 
 add_action( ‘catchbox_headercontent’, ‘catchbox_headerdetails_child’, 15 );
 function catchbox_headerdetails_child() { ?>
 <div class="logo-wrap clearfix">
 <?php
 // Check to see if the header image has been removed
 $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 ?>
 <hgroup id="site-details">
 <h1 id="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 id="site-description"><?php bloginfo( ‘description’ ); ?></h2>
 </hgroup>
 </div><!– .logo-wrap –>
 <?php }March 12, 2013 at 11:15 am #5012Sakin KeymasterI have also emailed you the code. March 12, 2013 at 12:25 pm #5026Robertf ParticipantThanks, Sakin. I added your functions.php to my Child Theme and it works as I’d hoped it would. However, I am glad that you wrote it because the unhooking of the default functions looked far more technical than I thought it would be! Hopefully that will be the last bit of customising I need to do. Regards, Robertf PS. Will give you a big plug in the WP Themes forum 😉 March 12, 2013 at 12:29 pm #5027Sakin Keymaster@Robertf: Yes. I didn’t realize the unhooking process and simply gave you the function. As I am supporting a lot of users. But I am happy that finally it worked for you. PS. Are you writing plugin or review of theme. March 12, 2013 at 12:32 pm #5029Robertf ParticipantSakin, I will write a review of the Catch Box Pro theme, which I have found to be an excellent base for a responsive template and one that can be customised without too much technical know-how … except for the unhooking process, which I think is a WordPress issue, not a problem with the theme 😉 Regards, Robert March 12, 2013 at 12:38 pm #5030Sakin KeymasterYes Robert, The unhooking process is the WordPress hook. Thanks for using Catch Box Pro theme. 
- 
		AuthorPosts
- The topic ‘Multiple H1 tags on blog posts & pages’ is closed to new replies.
