-
-
Save leewillis77/b126167de7f136e0a32ebd39346cbe98 to your computer and use it in GitHub Desktop.
Exclude categories from the feed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function lw_gpf_exclude_product($excluded, $product_id, $feed_format) { | |
// Return TRUE to exclude a product, FALSE to include it, $excluded to use the default behaviour. | |
$cats = wp_get_post_terms( $product_id, 'product_cat', array( 'fields' => 'ids' ) ); | |
if ( in_array( 21, $cats ) ) { | |
return TRUE; | |
} | |
return $excluded; | |
} | |
add_filter( 'woocommerce_gpf_exclude_product', 'lw_gpf_exclude_product', 11, 3); |
Hi;
These snippets are part of the support for the Google Product Feed plugin. If you need assistance you'd need to open a ticket here: https://woocommerce.com/my-account/create-a-ticket/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! Does this code exclude some products from a category? And how should I do to completely exclude all the products from the category?