Created
September 28, 2016 19:39
-
-
Save Dilden/9434913e456fcb1cdb141685d9fb671f to your computer and use it in GitHub Desktop.
Useful snippet for overriding WooCommerce templates in your custom WordPress plugin. Just follow the same directory structure as if you were overriding the templates from a theme.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Override woocommerce templates with the templates in my plugin | |
add_filter( 'woocommerce_locate_template', 'custom_plugin_templates'); | |
function custom_plugin_templates ( $template, $template_name, $template_path ) { | |
$check_dis = str_replace('woocommerce', 'your-plugin-name-goes-here/woocommerce', $template); | |
if(file_exists($check_dis)) { | |
$template = $check_dis; | |
} | |
return $template; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment