The WooCommerce settings provide an option to disable the shop page, but if you have a page called ‘shop’ then WooCommerce will still load the page using the products archive template:
/wp-content/plugins/woocommerce/templates/archive-product.php
This template file can be copied to your theme folder and then edited allowing the content to be changed (full details in the The Woo Themes Documentation). The file needs to be created in a folder called ‘woocommerce’ in the active theme:
/wp-content/theme-name/woocommerce/archive-product.php
This technique lets you change the content, but we wanted the page to load as if it was a normal page. To achieve this the page content is reloaded by calling query_posts
and then including the desired theme template for the page (in this case page.php):
<?php // override archive-product.php // load specific page query_posts('page_id=2'); // load the page template for the current theme include get_template_directory() . "/" . "page.php"; // stop any other woocommerce code executing exit; ?>
This solution (hack) is not ideal and the problem may well be resolved in a future revision of WooCommerce.
Previously the template page was named archive-template.php
and this post has been updated to the newly named archive-product.php
– thanks to Nancy for pointing this out.
7 Comments
This is an AWESOME post!
There is so much funk when it comes to Wordpress and Woocommerce and your post helped me get my shop page working the way I wanted.
Just a couple of things I came across to get this to work:
1. archive-template.php is now called archive-product.php. But that didn’t really matter because…
2. I am using a custom theme that has a woocommerce.php in the theme directory (/my-theme). Which was overriding my-theme/woocomerce/archive-product.php. So I had to place your code in the /my-theme/woocommerce.php file.
Thanks Nancy. I had to use this technique last week for another website and found the same thing. I’ll update my post!
Hello. I’m using your code for a year now I’m still liky with it. Just now the update of my SEO-Plugin AllinoneSEO broke my Shop-Page displayed with your code. Do you have an Idea what could be the reason? If I disable your code the ‘standart’ Woocommerce Product-Archive works. Thank you and best regards Simon
Hi Simon.
Did you get any error messages? That should give a clue to what the problem might be. What versions of WordPress, WooCommerce and All In One Seo Pack are you using?
Nick
Hello Nick,
sorry I didn’t see you replied to the message :/.
So the AllinoneSeo Support was able to solve the problem. But they said that this code use “query_post” in a “wrong” way. Is there any other way to achive the same thing?
Simon
Hi Simon,
What was the solution as it may help others?
This approach is definitely a ‘hack’ but was the simplest way to solve the problem. I thought this would likely be something that WooCommerce would resolve with future updates. I did look at a number of other options, but this was the simplest.
Nick
Hey Nick,
unfortunately the support didn’t tell me how they fixed the problem. But they included the fix in the next update.
Ok just wondered if there is a better solution.