Secondary Footer
-
I’m having trouble adding a secondary footer. I was able to add a secondary header in the child theme by creating a duplicate file (header-alt.php) in the root and template-parts folder, duplicating the function to render in the init.php file, and adding a condition to call it in page.php. In both folders I included the original header.php file along with the alt version, and it’s worked perfectly.
I replicated this process to make a second footer, but this time it’s not working.
I think the issue is occurring when the new footer file in the theme-root tries connecting to the new file in /template-parts/ folder. Adding <?php get_footer(‘alt’); ?> to the index is definitely reaching footer-alt file, but when I change the root footer-alt.php file the footer just disappears from the page. I can also see that the code connecting them is set up differently than it was in the header file.
This is the function in the init file:
function wpbf_do_footer2() { get_template_part( 'inc/template-parts/footer-alt' ); } add_action( 'wpbf_footer2', 'wpbf_do_footer2' );This is the changed line in the theme child-theme/footer-alt.php
do_action( 'wpbf_before_footer' ); if ( 'none' !== get_theme_mod( 'footer_layout' ) ) { do_action( 'wpbf_footer2' ); } do_action( 'wpbf_after_footer' );In the header there wasn’t a condition between the before/after, just
<?php do_action( 'wpbf_header2' ); ?>– I wonder if there’s something I’m missing here that is causing it not to work, or if I missed a step creating the action.Any ideas?
Thank you,
NatalieThe page I need help with: [log in to see the link]
-
Hi Natalie,
I would suggest to copy the footer.php file (the one from the template-parts folder) into your child theme and add it before the footer using the
wpbf_before_footerhook.function prefix_your_function() { get_template_part( 'footer-2' ); } add_action( 'wpbf_before_footer', 'prefix_your_function' );I’ve just tested this and moved the footer.php to the child-theme’s root folder (also renamed it to footer-2.php). Worked fine for me 🙂
Please let me know if that’s what you’re looking for.
Best,
David
The topic ‘Secondary Footer’ is closed to new replies.
