I'm having a hard time trying to override my parent theme's footer.php
, footer-set.php
and footer-tag.php
from my child theme.
I have just tried to copy-paste and modify them. No success. Maybe they are being read but probably later on, the ones from the parent prevail.
I have also tried to request them from the functions.php
in the child theme with no luck:
<?php
function my_theme_enqueue_styles() {
$parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
require_once get_stylesheet_directory() . '/footer.php';
require_once get_stylesheet_directory() . '/footer-set.php';
require_once get_stylesheet_directory() . '/footer-tag.php';
/*include( get_stylesheet_directory() . '../footer.php' );
include( get_stylesheet_directory() . '../footer-set.php' );
include( get_stylesheet_directory() . '../footer-tag.php' ); */
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>
The child theme is active and it works. I know this because the style.css works - it has effect. Also if i write something wrong in the functions.php in the child folder, it would throw an error. So it parses the functions.php fom the child theme.
I presume I have to de-register the footer.php
somewhere/somehow, but I have no idea where and how to.
This is my parent's theme structure, and these 3 are the files I am trying to override.
And this is what i added in the child theme:
As more info in case it would be useful, this is how the footer.php looks like:
<?php if ( tt_is_sidebar_active('footer_widget_area') ) { ?>
<section id="footer-widgets" class="clear">
<ul class="content-block xoxo">
<?php dynamic_sidebar('footer_widget_area'); ?>
</ul>
</section>
<?php } ?>
</section>
<?php global $template_url;?>
<footer id="footer">
<section class="content-block" style="margin-bottom:0;">
<p class="copyright left">© <?php echo date('Y');?> Queen Latifah Weight Loss</a>
| Theme By <a href="" title="All In One Theme" rel="nofollow">All In One Theme</a></p>
<ul id="footer-nav" class="right">
<li><a href="<?php bloginfo('url');?>" title="Visit HomePage">Home</a></li>
<?php //About Us Page
$footer_item = get_option('tt_footer_about');
if($footer_item && $footer_item != '' && is_numeric($footer_item)) {
$page = get_page($footer_item);
?>
<li><a href="<?php echo get_permalink($footer_item);?>" title="<?php echo $page->post_title; ?>">About</a></li>
<?php
}
unset($footer_item); unset($page);
?>
<?php //Terms Of Service Page
$footer_item = get_option('tt_footer_tos');
if($footer_item && $footer_item != '' && is_numeric($footer_item)) {
$page = get_page($footer_item);
?>
<li><a href="<?php echo get_permalink($footer_item);?>" title="<?php echo $page->post_title; ?>" rel="nofollow">Terms Of Service</a></li>
<?php
}
unset($footer_item); unset($page);
?>
<?php //Privacy Policy Page
$footer_item = get_option('tt_footer_privacy');
if($footer_item && $footer_item != '' && is_numeric($footer_item)) {
$page = get_page($footer_item);
?>
<li><a href="<?php echo get_permalink($footer_item);?>" title="<?php echo $page->post_title; ?>" rel="nofollow">Privacy Policy</a></li>
<?php
}
unset($footer_item); unset($page);
?>
<?php //Contact Us Page
$footer_item = get_option('tt_footer_contact');
if($footer_item && $footer_item != '' && is_numeric($footer_item)) {
$page = get_page($footer_item);
?>
<li><a href="<?php echo get_permalink($footer_item);?>" title="<?php echo $page->post_title; ?>" rel="nofollow">Contact</a></li>
<?php
}
unset($footer_item); unset($page);
?> <li><a href="/" title="Resources" rel="nofollow">Resources</a></li>
</ul>
</section>
</footer>
<?php wp_footer();?>
</body>
</html>
I also have this in functions.php:
//Get Theme Specific Footer
function tt_get_footer() {
$footer = get_option('tt_footer_layout');
if($footer == 'tag') {
include('footer-tag.php');
} else if ($footer == 'set') {
include('footer-set.php');
} else if ($footer == 'custom' || $footer == 'no') {
include('footer.php');
}
}
At the end of index.php I have:
<?php tt_get_footer(); ?>
I'm having a hard time trying to override my parent theme's footer.php
, footer-set.php
and footer-tag.php
from my child theme.
I have just tried to copy-paste and modify them. No success. Maybe they are being read but probably later on, the ones from the parent prevail.
I have also tried to request them from the functions.php
in the child theme with no luck:
<?php
function my_theme_enqueue_styles() {
$parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
require_once get_stylesheet_directory() . '/footer.php';
require_once get_stylesheet_directory() . '/footer-set.php';
require_once get_stylesheet_directory() . '/footer-tag.php';
/*include( get_stylesheet_directory() . '../footer.php' );
include( get_stylesheet_directory() . '../footer-set.php' );
include( get_stylesheet_directory() . '../footer-tag.php' ); */
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>
The child theme is active and it works. I know this because the style.css works - it has effect. Also if i write something wrong in the functions.php in the child folder, it would throw an error. So it parses the functions.php fom the child theme.
I presume I have to de-register the footer.php
somewhere/somehow, but I have no idea where and how to.
This is my parent's theme structure, and these 3 are the files I am trying to override.
And this is what i added in the child theme:
As more info in case it would be useful, this is how the footer.php looks like:
<?php if ( tt_is_sidebar_active('footer_widget_area') ) { ?>
<section id="footer-widgets" class="clear">
<ul class="content-block xoxo">
<?php dynamic_sidebar('footer_widget_area'); ?>
</ul>
</section>
<?php } ?>
</section>
<?php global $template_url;?>
<footer id="footer">
<section class="content-block" style="margin-bottom:0;">
<p class="copyright left">© <?php echo date('Y');?> Queen Latifah Weight Loss</a>
| Theme By <a href="http://allinonetheme" title="All In One Theme" rel="nofollow">All In One Theme</a></p>
<ul id="footer-nav" class="right">
<li><a href="<?php bloginfo('url');?>" title="Visit HomePage">Home</a></li>
<?php //About Us Page
$footer_item = get_option('tt_footer_about');
if($footer_item && $footer_item != '' && is_numeric($footer_item)) {
$page = get_page($footer_item);
?>
<li><a href="<?php echo get_permalink($footer_item);?>" title="<?php echo $page->post_title; ?>">About</a></li>
<?php
}
unset($footer_item); unset($page);
?>
<?php //Terms Of Service Page
$footer_item = get_option('tt_footer_tos');
if($footer_item && $footer_item != '' && is_numeric($footer_item)) {
$page = get_page($footer_item);
?>
<li><a href="<?php echo get_permalink($footer_item);?>" title="<?php echo $page->post_title; ?>" rel="nofollow">Terms Of Service</a></li>
<?php
}
unset($footer_item); unset($page);
?>
<?php //Privacy Policy Page
$footer_item = get_option('tt_footer_privacy');
if($footer_item && $footer_item != '' && is_numeric($footer_item)) {
$page = get_page($footer_item);
?>
<li><a href="<?php echo get_permalink($footer_item);?>" title="<?php echo $page->post_title; ?>" rel="nofollow">Privacy Policy</a></li>
<?php
}
unset($footer_item); unset($page);
?>
<?php //Contact Us Page
$footer_item = get_option('tt_footer_contact');
if($footer_item && $footer_item != '' && is_numeric($footer_item)) {
$page = get_page($footer_item);
?>
<li><a href="<?php echo get_permalink($footer_item);?>" title="<?php echo $page->post_title; ?>" rel="nofollow">Contact</a></li>
<?php
}
unset($footer_item); unset($page);
?> <li><a href="http://www.queenlatifahweightloss/resources/" title="Resources" rel="nofollow">Resources</a></li>
</ul>
</section>
</footer>
<?php wp_footer();?>
</body>
</html>
I also have this in functions.php:
//Get Theme Specific Footer
function tt_get_footer() {
$footer = get_option('tt_footer_layout');
if($footer == 'tag') {
include('footer-tag.php');
} else if ($footer == 'set') {
include('footer-set.php');
} else if ($footer == 'custom' || $footer == 'no') {
include('footer.php');
}
}
At the end of index.php I have:
<?php tt_get_footer(); ?>
Share
Improve this question
edited Feb 7, 2017 at 13:55
treisto
asked Feb 7, 2017 at 9:35
treistotreisto
211 silver badge3 bronze badges
4
- Did you activate the child theme? – Max Yudin Commented Feb 7, 2017 at 11:48
- Yep, the child is active and it works. I know this because the style.css works - it has effect. Also if i write something wrong in the functions.php in the child folder, it would throw an error. So it reads the functions.php fom the child theme – treisto Commented Feb 7, 2017 at 12:20
- I doubt your theme fully supports child themes. There was not mentioned otherwise on their site. – Max Yudin Commented Feb 7, 2017 at 13:16
- If it should have been built to support child themes, then yes, it is indeed a very high chance it doesn't support child themes. Should I just declare this case closed in this case?, there is usually more pain than gain if one tries to customize a theme which was not built on purpose with a child theme in mind? – treisto Commented Feb 7, 2017 at 13:42
4 Answers
Reset to default 1My friend, just take a look at their codex here https://codex.wordpress/Function_Reference/get_footer and you will know how. In your case, no need to add these
require_once get_stylesheet_directory() . '/footer.php';
require_once get_stylesheet_directory() . '/footer-set.php';
require_once get_stylesheet_directory() . '/footer-tag.php';
You only need to repair your tt_get_footer
like this
//Get Theme Specific Footer
function tt_get_footer() {
$footer = get_option('tt_footer_layout');
if($footer == 'tag') {
get_footer('tag');
} else if ($footer == 'set') {
get_footer('set');
} else {
get_footer(); // This one will use footer.php
}
}
Then you will get your child theme footer overriding
Quickly looking over this as work...
But add:
<?php get_footer(); ?>
into your template files (This should be there... you may have to call the footer-set.php and footer-tag.php files too)
you shouldn't need:
require_once get_stylesheet_directory() . '/footer.php';
require_once get_stylesheet_directory() . '/footer-set.php';
require_once get_stylesheet_directory() . '/footer-tag.php';
In your Functions.php
too
If this is incorrect ill help more when I'm home
First of all you don't need to call footer files inside functions.php
file. So remove these lines first.
require_once get_stylesheet_directory() . '/footer.php';
require_once get_stylesheet_directory() . '/footer-set.php';
require_once get_stylesheet_directory() . '/footer-tag.php';
As you said your child theme is working fine so let's debug why your footer.php file is not working.
I don't know where you are calling footer-set.php
and footer-tag.php
I am assuming you need them inside footer.php
file.
For debugging remove old files for now and create new file with the name of footer.php
and leave it empty only closing body
and html
tags will be there.
Then your footer should be empty on front-end try try these steps and then let me know what happens.
It seems like the theme do not use the wordpress "theme agnostic" template loading APIs, in this case get_footer
, or any other flexible way, which means that the footer just can not be changed by a child theme.