Tag: WooCommerce

Disable WooCommerce Content on Shop Page

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.

Posted in Programming | Also tagged , | 7 Comments