How to override WooCommerce templates via a WordPress theme

It is normal that one needs to modify a WooCommerce shop’s templates. It is not recommended to change the files in WooCommerce (WC) plugin directory. Fortunately, WC provides us a way to override template files via a theme.

WC template files contain the markup and template structure for frontend and HTML emails of a store. These files contain hooks that allow you to add/move content without needing to edit template files themselves. Besides, we can modify the files directly after copying those files to theme folder.

Under wp-content\plugins\woocommerce\templates, you will find all template files that the plugin use.

Copy the whole templates folder and copy to your theme as woocommerce folder. So woocommerce\templates will becomee your-theme\woocommerce.

That’s to override all files, but if you only need to modify a certain template, just copy only that file. But you still need to keep the folder structure.

The template for shop page is archive-product.php. To override the shop page, copy: wp-content/plugins/woocommerce/templates/archive-product.php to wp-content/themes/yourtheme/woocommerce/archive-product.php.

If you theme doens’t support WooCommerce yet, trigger the support with following lines in functions.php.

function yourtheme_add_woocommerce_support() {
    add_theme_support( 'woocommerce' );
add_action( 'after_setup_theme', 'yourtheme_add_woocommerce_support' );

Leave a Comment

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.