Last active
July 21, 2023 08:16
-
-
Save wp-seopress/8237fab5df29485f8365bc454f75fc81 to your computer and use it in GitHub Desktop.
Exclude out of stock WooCommerce products from the XML sitemap
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
function sp_sitemaps_single_query($args, $cpt_key) { | |
if ( $cpt_key == 'product' ) { | |
$args['tax_query'][] = array( | |
'taxonomy' => 'product_visibility', | |
'field' => 'slug', | |
'terms' => ['exclude-from-catalog', 'outofstock'], | |
'operator' => 'NOT IN', | |
); | |
} | |
return $args; | |
} | |
add_filter('seopress_sitemaps_single_query', 'sp_sitemaps_single_query', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment