Woocommerce Google Product Feed – exclude / hide all products by default

If you love using WooCommerce as an ecommerce tool like me, at some point you will probably look into using the Google Product Feed extension.

This extension creates a feed for Google Merchant Center to pull from so your products show up in the Google Products section of search results. It’s a great extension and you can check it out at: http://www.woothemes.com/products/google-product-feed/

That said, I ran into an issue with this extension. By default the extension adds all products to the feed. There is a section on each WooCommerce product page that gives you the option to exclude the product feed.

This is a nice feature, but if you are like me and have a client that has 250 products and only wants to include 3 of those products in the feed what do you do?

[bctt tweet=”I don’t want go through each product and click the exclude button. That would take forever!!”]

I think a nice improvement to this extension would be to include a feature to exclude all products except the ones that you choose. Hopefully at some point Lee Willis the extension developer will add this.

Okay, so it’s kind of an ugly hack but this is how I resolved the issue for myself:

In your WordPress plugins directory open file: /plugins/woocommerce-product-feeds/woocommerce-gpf-frontend.php

On line 189 change:
if ( isset ( $tmp_product_data['exclude_product'] ) ) continue;


if ( !isset ( $tmp_product_data['exclude_product'] ) ) continue;
Now all products will be excluded automatically. If you want to include a product in the feed you have to go to the products page and check the “Hide this product from the feed”. It’s a little backwards, but at this point you could stop and it would work for you.

If you want to fix it so it makes sense from a users point of view you can open: /plugins/woocommerce-product-feeds/woocommerce-gpf-admin.php

On line 301 change:
echo '<label for="_woocommerce_gpf_data[exclude_product]">'.__(" Hide this product from the feed", 'woocommerce_gpf');


echo '<label for="_woocommerce_gpf_data[exclude_product]">'.__("Include this product in the feed", 'woocommerce_gpf');

The last thing you will have to do is remove the jquery slide reveal effect.

On line 334 to 344 delete:

Delete all of the code. It will be the code inside the javascript tags:
<script type="text/javascript">
jQuery('#woocommerce_gpf_excluded').change(function() {
if (jQuery("#woocommerce_gpf_excluded").is(':checked')) {
} else {

That’s it!! You have now changed the default to exclude all products. All you have to do now is go to the products pages you want to include and check the “Include this product in the feed”.

Remember that you are hacking the plugin/extension, so if you update it you will have to resolve this issue again.

I hope this helps.

Shawn Hayes

Team Share Web Design


  • Alex Timmer

    Good fix, though too bad it’s a core edit involved, something I’d rather not do. But this thread did get me on the right track to go figure out if I can set the “exclude this product from feed” option for all products via the database, and then changing it for the few products we do want to show.
    Quite a missed opportunity that there isn’t a global option for this, and that there IS some CSV-export functionality, but NOT for this specific exclude option..

    • Shawn Hayes

      Hi Alex,
      I totally agree!! I hate hacking plugins or anything core. I really wish the author would add this feature to the plugin. I am glad this helped you get on the right track though. Let me know if you have any questions about anything.

  • Rob

    Great Post – I have just downloaded the plugin and as like others can’t believe there is no default option to hide all products to start with. make sense to me.
    Anyway I was able to find the code on your first part (p189) even though it is further down and slightly different. The last two points that code is not where you say and anything similar to it is just too different to yours for me to risk changing. There is no reference to Javascript in the gpf-admin php file now.
    I understand there has probably been a lot of changes since you created this post and just curious if you have an updated version at all please?

    • Shawn Hayes

      Unfortunately no, I haven’t worked with the updated version. This was for version 3.5 back in November, 2014.
      Sorry about that.

  • Jitske

    I found your hack, but it seems that this file (/plugins/woocommerce-product-feeds/woocommerce-gpf-frontend.php) has changed. So I can’t use your solution.
    Can you help me with the latest version (6.8.0)?

    I have about 2500 products and I want only 10-20 in the Google product feed, so check the box for hiding the product would be quite a job;-)

    • Shawn Hayes

      I am really sorry you are in a bad spot. As mentioned in the comment above, I haven’t worked with the updated version. This was for version 3.5 back in November, 2014. If I do work with the new version I will definitely update the tutorial.

  • Daniel Hobson

    An alternative approach if you don’t want to hack plugin files is to run a query like the following to bulk set all the products to be excluded. Be wary though as this removes any associated feed data from all products, probably best to use immediately after plugin install.

    DELETE FROM wp_postmeta
    WHERE meta_key = ‘_woocommerce_gpf_data’;
    INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
    SELECT ID, ‘_woocommerce_gpf_data’, ‘a:1:{s:15:”exclude_product”;s:2:”on”;}’ FROM wp_posts WHERE post_type = ‘product’;

    • Shawn Hayes

      Thank you for the tip Daniel. I am not super great at SQL queries but this looks pretty simple. I will have to give it go when I have a chance. Thanks again!

  • Lee Burrett

    Have tried the SQL query that Daniel has suggested – whilst everything looks ok in the database – doesn’t seem to make any change to the front end of the product – Hide from Feed checkbox is still unticked on all products. Have tried manually ticking against one product and the resulting meta_value string is exactly the same as specified above but can’t see any change in the dashboard for each product I’ve set via SQL…

    • Shawn Hayes

      Hi Lee,

      I am sorry Daniels suggestion didn’t work for you. I haven’t worked with this plugin in a few years, so I am probably not much help to you. My only suggestion is maybe try modifying my code above to work with the new version of the plugin.

  • Lee Willis (Plugin author)

    Thanks for the kind words about the plugin – glad you’ve found it useful.

    However – there’s really no need to modify the plugin to achieve this. There are filters that let you change whether a product is included, or excluded. That could easily be used to reverse the logic. The filter is explained here:


    That said, the current version of the plugin makes that field available for export / import via the WooCommerce built in exporter. So an even better solution is to run an export with the product ID, and the “Hide product from feed” field, e.g.


    Then simply set any you want as excluded to “Y” in the CSV file, and upload it and it will set the products to excluded for you.

    As a general note, if there’s something you want the plugin to do then a support request is always a good start. Even if you want is custom, I’m always open to adding filters / hooks so that it’s possible to do what you want without modifying the plugin.

    • Shawn Hayes

      Nice!! Thank you so much Lee for you input.

      As mentioned above, I haven’t used your plugin in several years but I am sure this will help others if they are having this problem.

      I will change the blog content to what you described when time permits.

      Thanks again.

  • Sam

    i have the new version and still i am not able to sort this out using the import as i cant map the fields as it will not let me as it only offers 2 dropdowns to pick a field. also when i try to import it just ads blank items and calls them “Product”

    Cant Lee Willis just add this to the plugin as an option to hide large amounts of items

    • Shawn Hayes

      Thanks for your comment Sam and I am sorry you are having difficulties.

      Maybe reach out to Lee Willis and make the request. I know this has been an issue for a few of my readers.

      Thanks again.

Leave a Reply

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

Featured Posts


Almost there! Please complete this form and click the button below to gain instant access.

Get The Full Guide & Example Files:

It makes setting up your AJAX code super simple!