Last active
May 14, 2025 08:37
-
-
Save webdados/6d4e6926673303f0728a94b3f279b4ea to your computer and use it in GitHub Desktop.
Include only certain categories on / Exclude categories from the KuantoKusta WooCommerce feed
This file contains hidden or 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 | |
// Get the plugin from: | |
// Free version: https://pt.wordpress.org/plugins/feed-kuantokusta-for-woocommerce/ | |
// Add-on PRO add-on: https://nakedcatplugins.com/product/feed-kuantokusta-for-woocommerce-pro/ | |
// Only show products with specific categories | |
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 my_include_kk_categories( $show, $product ) { | |
// If not shown already, 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; | |
} | |
// Do not show products with specific categories | |
add_filter( 'kuantokusta_product_node_show', 'my_exclude_kk_categories', 10, 2 ); | |
add_filter( 'kuantokusta_variation_node_show', 'my_exclude_kk_categories', 10, 2 ); | |
function my_exclude_kk_categories( $show, $product ) { | |
// If not shown already, we don't neeed to process the item | |
if ( $show ) { | |
// Product categories IDs to exclude from the feed | |
$categories_to_exclude = array( | |
333, | |
336, | |
); | |
// Has at least one category? Return false | |
if ( has_term( $categories_to_exclude, 'product_cat', $product->get_id() ) ) return false; | |
} | |
// Return | |
return $show; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment