I am having an issue with a theme I am using.
The parent theme has created a woocommerce.php file. When this file exists, it takes precedence over the woocommerce hooks, and it causes issues when I want to use hooks to add content before the woocommerce content.
Is it possible for a child theme to declare that the woocommerce.php file from parent should be ignored ?
I am having an issue with a theme I am using.
The parent theme has created a woocommerce.php file. When this file exists, it takes precedence over the woocommerce hooks, and it causes issues when I want to use hooks to add content before the woocommerce content.
Is it possible for a child theme to declare that the woocommerce.php file from parent should be ignored ?
Share Improve this question asked Jan 30, 2018 at 14:02 MartinMartin 1033 bronze badges 5 |1 Answer
Reset to default 0The child theme could just delete the parent theme file if it exists (via child theme functions.php). eg.
$template = get_template_directory().'/woocommerce.php';
if (file_exists($template)) {unlink($template);}
That would continue to override it if it came to exist again (ie. after a parent theme update.) If you aren't going to update the parent theme just delete it's woocommerce.php
If it's a file other than the WooCommerce files and just another file in the parent theme, copy it into the child theme and remove it's content just leave the <?php ?>
tags if the content of the file is not needed.
woocommerce.php
file in the child theme? – Tom J Nowell ♦ Commented Jan 30, 2018 at 14:52require( get_template_dir().'/woocommerce.php' );
thenremove_action
andremove_filter
your way to success – Tom J Nowell ♦ Commented Jan 30, 2018 at 19:54