Plugin Support
Peter
(@petersquirrly)
Hi,
Please try to put in SEO Snippet > Visibility and switch off to “Let Squirrly Index It”.
Also, can you let us know for which URL and product do you wish to do this?
Thread Starter
trmkr
(@trmkr)
Hi Peter,
I have ~500 products and ~300 of them are out of stock. I want to exclude all out of stock products from sitemap. I would be grateful if there is an easy way to do this. I used this code for noindex tag.
//Hook the Squirrly sq_noindex for post_ids
add_filter('sq_noindex', function ($robots) {
$robots = array();
global $post;
if ($post->post_type == 'product') {
$product = wc_get_product( $post );
if (!$product->is_in_stock())
$robots[] = 'noindex';
$robots[] = 'nofollow';
}
return $robots;
}, 11);
Regards
-
This reply was modified 3 years, 1 month ago by
trmkr.
Plugin Support
Peter
(@petersquirrly)
Thread Starter
trmkr
(@trmkr)
Hi Peter,
Thank you for your efforts! This code solved my problem. I tested it and it works perfectly! Thanks for this great SEO plugin.
Regards
Plugin Support
Peter
(@petersquirrly)
That’s really great to hear! Thank you for the kind words and the confirmation.