plugin development – Exclude Woocommerce Product Category From Sitemap

Question

Am trying to exclude 2 specific product categories from default WordPress sitemap.

Any help how to archive this?

 'wp_sitemaps_posts_query_args',
 function( $args, $post_type ) {
     if ( 'product_cat' !== $post_type ) {
         return $args;
     }

     $args['product_cat__not_in'] = isset( $args['product_cat__not_in'] ) ? $args['product_cat__not_in'] : array();
     $args['product_cat__not_in'][] = 2053;
     $args['product_cat__not_in'][] = 924;
     return $args;
 },
 10,
 2
);

0
sot 6 months 2022-06-19T06:17:24-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse