woocommerce_template_path
Allows you to change the relative path to the WooCommerce templates directory in the theme.
By default, WooCommerce templates can be overridden by creating a woocommerce directory in the theme root and reproducing the relative file paths and names from the plugin directory (wp-content/plugins/woocommerce/templates).
Usage
add_filter( 'woocommerce_template_path', 'wp_kama_woocommerce_template_path_filter' );
/**
* Function for `woocommerce_template_path` filter-hook.
*
* @param $string
*
* @return
*/
function wp_kama_woocommerce_template_path_filter( $string ){
// filter...
return $string;
}
- $string(string)
- The relative path to the WooCommerce templates directory in the theme.
Default: 'woocommerce/'
Examples
#1 Change the path to the WooCommerce templates directory in the theme
add_filter( 'woocommerce_template_path', function () {
return 'templates/shop/';
} );Where the hook is called
woocommerce_template_path
woocommerce/includes/class-woocommerce.php 1187
return apply_filters( 'woocommerce_template_path', 'woocommerce/' ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingSinceComment