Skip to content

Instantly share code, notes, and snippets.

@webdados
Created June 4, 2021 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdados/6d4e6926673303f0728a94b3f279b4ea to your computer and use it in GitHub Desktop.
Save webdados/6d4e6926673303f0728a94b3f279b4ea to your computer and use it in GitHub Desktop.
Include only certain products on the KuantoKusta WooCommerce feed
<?php
//Get the plugin from https://www.webdados.pt/wordpress/plugins/feed-kuantokusta-para-woocommerce/
add_filter( 'kuantokusta_product_node_show', 'my_include_kk_categories', 10, 2 );
add_filter( 'kuantokusta_variation_node_show', 'my_include_kk_categories', 10, 2 );
function include_kk_categories( $show, $product ) {
//If not show, we don't neeed to process the item
if ( $show ) {
//Init as false
$show = false;
//Product categories IDs to include in the feed
$categories_to_include = array(
333,
336,
);
//Has at least one category? Return true
if ( has_term( $categories_to_include, 'product_cat', $product->get_id() ) ) return true;
}
//Return
return $show;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment