So we started YACP (Yet Another ClassiPress Theme) tonight and we are making a modification that unfortunately requires us to overwrite the entire header area. We want to be smart about this so I searched around for a good hook or filter to handle the customization. Thankfully I found one called called “cp_header” which is added to “appthemes_header”. I thought to myself “great, this will be easy!”
So I added a few lines to my child theme functions.php file only to find out that when I tried removing the original header…. no luck. There is a little problem with the scope of removing the appthemes header from your child theme so I’m providing another free tutorial and code bit that will save you a few hours of frustration.
Add this to your functions.php file and create a file called “part.theme-custom.header.inc.php” to allow your child theme to load a custom header file to replace the existing header area below the body opening tag… without breaking anything else in ClassiPress. Oh, you may want to copy the original header code too, so I’ll include the “current version” of this code below also.
add_action('appthemes_init', 'remove_cp_parts'); function remove_cp_parts() { remove_action('appthemes_header', 'cp_header'); } add_action('appthemes_header', 'custom_cp_header'); function custom_cp_header(){ get_template_part('part.theme','custom.header.inc'); }
<!-- HEADER --> <div class="header"> <div class="header_top"> <div class="header_top_res"> <p> <?php echo cp_login_head(); ?> <a href="<?php if (get_option('cp_feedburner_url')) echo get_option('cp_feedburner_url'); else echo get_bloginfo_rss('rss2_url').'?post_type='.APP_POST_TYPE; ?>" target="_blank"><img src="<?php bloginfo('template_url'); ?>/images/icon_rss.gif" width="16" height="16" alt="rss" class="srvicon" /></a> <?php if ( get_option('cp_twitter_username') ) : ?> | <a href="http://twitter.com/<?php echo get_option('cp_twitter_username'); ?>" target="_blank"><img src="<?php bloginfo('template_url'); ?>/images/icon_twitter.gif" width="16" height="16" alt="tw" class="srvicon" /></a> <?php endif; ?> </p> </div><!-- /header_top_res --> </div><!-- /header_top --> <div class="header_main"> <div class="header_main_bg"> <div class="header_main_res"> <div id="logo"> <?php if ( get_option('cp_use_logo') != 'no' ) { ?> <?php if ( get_option('cp_logo') ) { ?> <a href="<?php echo home_url(); ?>"><img src="<?php echo get_option('cp_logo'); ?>" alt="<?php bloginfo('name'); ?>" class="header-logo" /></a> <?php } else { ?> <a href="<?php echo home_url(); ?>"><div class="cp_logo"></div></a> <?php } ?> <?php } else { ?> <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1> <div class="description"><?php bloginfo('description'); ?></div> <?php } ?> </div><!-- /logo --> <?php if ( get_option('cp_adcode_468x60_enable') == 'yes' ) { ?> <div class="adblock"> <?php appthemes_header_ad_468x60();?> </div><!-- /adblock --> <?php } ?> <div class="clr"></div> </div><!-- /header_main_res --> </div><!-- /header_main_bg --> </div><!-- /header_main --> <div class="header_menu"> <div class="header_menu_res"> <a href="<?php echo CP_ADD_NEW_URL ?>" class="obtn btn_orange"><?php _e('Post an Ad', 'appthemes') ?></a> <ul id="nav"> <li class="<?php if (is_home()) echo 'page_item current_page_item'; ?>"><a href="<?php echo get_option('home')?>"><?php _e('Home','appthemes'); ?></a></li> <li class="mega"><a href="#"><?php _e('Categories','appthemes'); ?></a> <div class="adv_categories" id="adv_categories"> <?php echo cp_create_categories_list( 'menu' ); ?> </div><!-- /adv_categories --> </li> </ul> <?php wp_nav_menu( array('theme_location' => 'primary', 'fallback_cb' => 'appthemes_default_menu', 'container' => false) ); ?> <div class="clr"></div> </div><!-- /header_menu_res --> </div><!-- /header_menu --> </div><!-- /header -->
© Copyright 2024 Sethmatics Websites All Rights Reserved.