2

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.

enter image description here

And this is what i added in the child theme:

enter image description here

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">&copy; <?php echo date('Y');?> Queen Latifah Weight Loss</a>
             | Theme By <a href="http://allinonetheme.com" 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.com/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(); ?>
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 4

1

My friend, just take a look at their codex here https://codex.wordpress.org/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

0

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

4
  • Hello, thank you very much for the answer. Unfortunately I'm a real newbie so I must ask: do I have to add this "<?php get_footer(); ?>" to one of the parent's files? Cause I have a feeling it would somehow defeat the purpose as it would be erased when the theme updates and I will have to add it again? Or, if it should be in the child theme, where exactly please? Cause I've just added it in the footer.php and it doesn't do anything... I've added it in the beginning like this: "<?php get_footer(); ?> <?php if ( tt_is_sidebar_active('footer_widget_area') ) { ?> .............."
    – treisto
    Commented Feb 7, 2017 at 13:07
  • The theme will not be updated. That project is dead.
    – Max Yudin
    Commented Feb 7, 2017 at 13:19
  • I would still prefer to do it like this if possible, for 2 reasons: I want to learn and understand how the child-themes work. Second, if I want to put this theme on other sites, if I have all the modifications in one place it will be easier to remember what I have changed and where and why.
    – treisto
    Commented Feb 7, 2017 at 13:29
  • I found this at the end of index.php: <?php tt_get_footer(); ?> Could it be related?
    – treisto
    Commented Feb 7, 2017 at 13:30
0

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.

4
  • Thanks a lot for the answer. I found 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'); } }
    – treisto
    Commented Feb 7, 2017 at 13:33
  • I should place the empty footer.php in the parent theme, I presume?
    – treisto
    Commented Feb 7, 2017 at 13:39
  • I have created the empty footer as you said, and i have uploaded it in the parent theme structure. The effect is that now there is no footer on the website
    – treisto
    Commented Feb 7, 2017 at 13:52
  • I have also did this the other way around: keep the original footer in the parent theme and upload the empty footer.php in the child theme. Result: on the site the full original header is displayed.
    – treisto
    Commented Feb 7, 2017 at 14:16
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.