- This topic has 7 replies, 2 voices, and was last updated 7 years, 4 months ago by Theme Horse Support Team.
-
AuthorPosts
-
July 19, 2017 at 10:46 pm #52254stanlin1999Participant
Trying to create a template that places a custom post UI image between the navigation bar and the title like this:
However, I am unable to override the header-extensions.php in my child folder to the parent
The page is displayed through single-program.php -> get_header(); -> header-extensions.php -> ambition_headercontent_details();
The code that is fit between the Navbar and the title:
</div><!-- .container --> <img id="single-program-banner" src="<?php the_field('banner'); ?>" alt="" /> </div><!-- .hgroup-wrap -->
Theme I’m using https://www.themehorse.com/preview/ambition/
Thank you
I tried looking at this post (# but when I create a functions.php file in my child folder, my page goes blank.
July 20, 2017 at 10:51 am #52274Theme Horse Support TeamKeymasterHi stanlin1999,
Creating the same structure in the child theme will not over ride the parent theme. First of all you need to unhook the function and then customize the code. We will post a simple example how to unhook to functions:-
Create a two files styles.css and functions.phpUnder style.css add this following code.
/* Theme Name: Ambition Child Theme Theme URI: https://www.themehorse.com/themes/ambition Author: Theme Horse Author URI: https://www.themehorse.com Text Domain: ambition Template: ambition */ @import url("../ambition/style.css");
Under functions.php file
// Unhook default Thematic functions function unhook_thematic_functions() { // Don't forget the position number if the original function has one add_action('ambition_header', 'ambition_headercontent_details', 10); } add_action('init','unhook_thematic_functions'); add_action( 'ambition_headercontent_details', 'ambition_child_headercontent_details', 10 ); funtion ambition_child_headercontent_details(){ // your stuff }
Thank you!
July 20, 2017 at 4:51 pm #52281stanlin1999ParticipantHi, thank you for your help.
I tried using your example code above for the functions.php, however, when I use it my site crashes
This page isn’t working localhost is currently unable to handle this request. HTTP ERROR 500
This is what my functions.php looks like. It is in my child folder ambition-child.
<?php // Unhook default Thematic functions function unhook_thematic_functions() { // Don't forget the position number if the original function has one add_action('ambition_header', 'ambition_headercontent_details', 10); } add_action('init','unhook_thematic_functions'); add_action( 'ambition_headercontent_details', 'ambition_child_headercontent_details', 10 ); function ambition_child_headercontent_details(){ <div> <img id="single-program-banner" src="<?php the_field('banner'); ?>" alt="" /> </div> } ?>
July 20, 2017 at 5:07 pm #52282stanlin1999ParticipantI was able to find a solution!!
I think you had a similar idea, but the answer in the following link added back the ambition_child_headercontent_details function in the child theme.
Cheers,
July 20, 2017 at 6:13 pm #52283stanlin1999ParticipantWeird, now when I try to public or preview pages, the page just hangs..
July 21, 2017 at 5:19 am #52288Theme Horse Support TeamKeymasterHi stanlin1999,
I have readded the action hook code which must be added in the child theme functions.php file.
<?php // Unhook default Thematic functions function unhook_thematic_functions() { // Don't forget the position number if the original function has one remove_action('ambition_header', 'ambition_headercontent_details', 10); } add_action('init','unhook_thematic_functions'); add_action( 'ambition_header', 'ambition_child_headercontent_details', 10 ); function ambition_child_headercontent_details(){global $ambition_settings; $header_image = get_header_image(); if (!empty($header_image)):?> <a href="<?php echo esc_url(home_url('/'));?>"><img src="<?php echo esc_url($header_image);?>" class="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> <?php endif;?> <div class="hgroup-wrap"> <div class="container clearfix"> <?php $ambition_settings = wp_parse_args( get_option( 'ambition_theme_settings', array() ), ambition_get_option_defaults() ); $header_display = $ambition_settings['header_settings']; $header_logo = $ambition_settings['img-upload-header-logo']; if ($header_display != 'disable_both' && $header_display == 'header_text') { ?> <section id="site-logo" class="clearfix"> <?php if(is_single() || (!is_page_template('page-templates/page-template-business.php' )) && !is_home()){ ?> <h2 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> </h2><!-- #site-title --> <?php } else { ?> <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><!-- #site-title --> <?php } $site_description = get_bloginfo( 'description', 'display' ); if($site_description){?> <h2 id="site-description"> <?php bloginfo('description');?> </h2> <?php } ?> </section><!-- #site-logo --> <?php } elseif ($header_display != 'disable_both' && $header_display == 'header_logo') { ?> <section id="site-logo" class="clearfix"> <?php if(is_single() || (!is_page_template('page-templates/page-template-business.php' )) && !is_home()){ ?> <h2 id="site-title"> <a href="<?php echo esc_url(home_url('/'));?>" title="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" rel="home"> <img src="<?php echo $header_logo;?>" alt="<?php echo esc_attr(get_bloginfo('name', 'display'));?>"></a> </h2> <?php }else{ ?> <h1 id="site-title"> <a href="<?php echo esc_url(home_url('/'));?>" title="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" rel="home"> <img src="<?php echo $header_logo;?>" alt="<?php echo esc_attr(get_bloginfo('name', 'display'));?>"></a> </h1> <?php } ?> </section><!-- #site-logo --> <?php }?> <button class="menu-toggle"><?php _e('Responsive Menu', 'ambition' ); ?></button> <?php if (has_nav_menu('primary')) {// if there is nav menu then content displayed from nav menu else from pages ?> <section class="hgroup-right"> <?php $args = array( 'theme_location' => 'primary', 'container' => '', 'items_wrap' => '<ul class="nav-menu">%3$s</ul>', ); ?> <nav id="site-navigation" class="main-navigation clearfix" role="navigation"> <?php wp_nav_menu($args);//extract the content from apperance-> nav menu ?> </nav><!-- #access --> <?php } else {// extract the content from page menu only ?> <section class="hgroup-right"> <nav id="site-navigation" class="main-navigation clearfix" role="navigation"> <?php wp_page_menu(array('menu_class' => 'nav-menu')); ?> </nav><!-- #access --> <?php } $search_form = $ambition_settings['search_header_settings']; if (1 != $search_form) { ?> <div class="search-toggle"></div><!-- .search-toggle --> <div id="search-box" class="hide"> <?php get_search_form();?> <span class="arrow"></span> </div><!-- #search-box --> <?php } ?> </section><!-- .hgroup-right --> </div><!-- .container --> </div><!-- .hgroup-wrap --> <?php global $disable_slider; global $ambition_settings; if (is_front_page()) { $disable_slider = $ambition_settings['disable_slider']; if (empty($disable_slider)) { if (function_exists('ambition_pass_slider_effect_cycle_parameters')) { ambition_pass_slider_effect_cycle_parameters(); } if (function_exists('ambition_featured_sliders')) { ambition_featured_sliders(); } } } else { if (('' != ambition_header_title()) || function_exists('bcn_display_list')) { $sitetitle_img_setting = $ambition_settings['site_title_setting']; $sitetitle_image = $ambition_settings['img-upload-site-title']; ?> <div class="page-title-wrap" <?php if ( $sitetitle_img_setting != '1' && $sitetitle_image != '' ){ ?> style="background-image:url('<?php echo esc_url($sitetitle_image);?>');" <?php } ?> > <div class="container clearfix"> <?php if(is_home()){?> <h2 class="page-title"><?php echo ambition_header_title();?></h2><!-- .page-title --> <?php } else { ?> <h1 class="page-title"><?php echo ambition_header_title();?></h1><!-- .page-title --> <?php } if (function_exists('ambition_breadcrumb')) { ambition_breadcrumb(); } ?> </div><!-- .container --> </div><!-- .page-title-wrap --> <?php } } } ?>
This will overwrite the parent header-extension.php file. You can customize in functions.php file as per your needs.
I am not sure what this code is for or is it from plugins. If you have added it unknownly then it will give Uncaught Error:Call to undefined function the_field()
which is not a known function.<div> <img id="single-program-banner" src="<?php the_field('banner'); ?>" alt="" /> </div>
Thank you!
July 21, 2017 at 7:01 pm #52299stanlin1999Participantthe the_field() is a custom field type function. I was able to get it working!
Turns out I have an extra whitespace right before <?php and it was throwing the error: ‘Cannot modify header information – headers already sent by’ Found the solution here:
https://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php
It’s great to see that you are able to offer help and support this fantastic theme 😀
July 24, 2017 at 10:08 am #52325Theme Horse Support TeamKeymasterThat’s great and thanks for sharing your information with us.
Thank you!
-
AuthorPosts
- You must be logged in to reply to this topic.