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.

This entry was posted in Programming and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

7 Comments

  1. Posted May 10, 2015 at 8:10 pm | Permalink

    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.

    • Posted May 11, 2015 at 7:34 am | Permalink

      Thanks Nancy. I had to use this technique last week for another website and found the same thing. I’ll update my post!

  2. Posted March 7, 2017 at 8:22 am | Permalink

    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

  3. Posted March 8, 2017 at 3:38 pm | Permalink

    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

    • Posted April 28, 2017 at 8:39 am | Permalink

      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

      • Posted April 28, 2017 at 9:01 am | Permalink

        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

        • Posted May 1, 2017 at 11:57 am | Permalink

          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.

Post a Reply to Nick Cancel Reply

*
*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

* = Required