Loading different header and footer in woocommerce templates
-
Hello,
I would like to use different header and footer instead of default one, I already achieved this but I can’t manage to do it for WooCommerce templates. So let me explain what is happening.
Website is using Storefront child theme, and the current structure looks like this:
– for the desktop version:
/mytheme/woocommerce/
– for the amp version:
/mytheme/amp/woocommerce/
– In order for the amp woocommerce templates to load, I use this code:function woo_amp_directory ($path){ if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) { $my_path = get_stylesheet_directory() . '/amp/woocommerce/'; return file_exists( $my_path ) ? 'amp/woocommerce/' : $path; } return $path; } add_filter ('woocommerce_template_path', 'woo_amp_directory');
Now I have my custom header & footer in the
/mytheme/amp/
directory and I load it using
get_template_part('amp/header', 'amp');
get_template_part('amp/header', 'amp');
However the WooCommerce templates are using the
get_header()
&get_footer()
function which loads the header from/mytheme/
. I would like to override this behaviour so the templates that are in/mytheme/amp/woocommerce/
use this:
get_template_part('amp/header', 'amp');
get_template_part('amp/header', 'amp');
instead of default ones.It doesn’t specifically need to use the get_template_part function, i just want these templates
/mytheme/amp/woocommerce/
to use/mytheme/amp/header.php
&/mytheme/amp/footer.php
.
- The topic ‘Loading different header and footer in woocommerce templates’ is closed to new replies.