I was trying to customize the shop page (adding widget area to the page). Is there any way or plugin to help me do so? I created a
page-shop.php
however no changes were seen.
-
Do you only want to add widgets to the shop page ?– user6552940Commented Feb 11, 2017 at 13:49
-
Yes, For now. I need them to display a search area and product categories area.– Roshan ChapagainCommented Feb 11, 2017 at 13:56
-
Thanks a lot. But, there is a 'woocommerce.php' file in my theme and the link says that I will be unable to override the 'archive-product.php' if its there. So is there any way to get around this?– Roshan ChapagainCommented Feb 11, 2017 at 14:08
-
I've updated my answer with the necessary steps.– user6552940Commented Feb 11, 2017 at 14:19
-
Or you can just use this plugin for that :D wordpress.org/plugins/woo-edit-templates– ioannupCommented May 12, 2018 at 20:05
3 Answers
The WooCommerce template files are different from the WordPress Template files look at this to see how it works and the template file for shop pages is archive-product.php
Usually, all themes provide a separate sidebar area for the shop page, did you check if your theme is compatible with WooCommerce?
If yes then you should have a sidebar available under Appearance->Widgets
with name similar to 'Shop Sidebar'
How to override a template?
To override the shop page,
copy: wp-content/plugins/woocommerce/templates/archive-product.php
to wp-content/themes/your_theme_name/woocommerce/archive-product.php
and then make the necessary changes to the template in your themes folder.
What happens is WooCommerce checks for the archive-product.php
file in theme directory first and if it finds a file in woocommerce/ directory then it will use that file instead of the default one.
So now you have to edit the file inside your_theme_folder/woocommerce
to make any changes.
-
You can override the template by copying it into your template folder as specified in the link and then making necessary changes. I will update the answer with instructions. Commented Feb 11, 2017 at 14:11
If you are using custom WooCommerce template overrides in your theme you need to declare WooCommerce support using the add_theme_support function. WooCommerce template overrides are only enabled on themes that declare WooCommerce support. If you do not declare WooCommerce support in your theme, WooCommerce will assume the theme is not designed for WooCommerce compatibility and will use shortcode-based unsupported theme rendering to display the shop.
Declaring WooCommerce support is straightforward and involves adding one function in your theme's functions.php file.
function mytheme_add_woocommerce_support() {
add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );
Now override the template file
copy: wp-content/plugins/woocommerce/templates/archive-product.php
to wp-content/themes/your_theme_name/woocommerce/archive-product.php
Please note if you trying to override woocommerce shop page such way as suggested above
To override the shop page, copy: wp-content/plugins/woocommerce/templates/archive-product.php to wp-content/themes/your_theme_name/woocommerce/archive-product.php
You also have impact on category shop pages.
If you want have only impact on shop page separately it will be better create new template in:
wp-content/themes/your_theme_name/archive-product.php