• Resolved Skrlance

    (@seanlance)


    How to prevent Woocommerce shop page appearing on product-sitemap.xml?

    I noindex and tried following code with functions.php but nothing removes it from product sitemap.

    add_filter( ‘wpseo_sitemap_post_type_archive_link’, ‘my_wpseo_cpt_archive_link’, 10, 2);
    function my_wpseo_cpt_archive_link( $link, $post_type ) {
    // Disable product/post archives in the sitemaps
    if ( $post_type === ‘product’ )
    return false;
    return $link;
    }

    Can you help me please!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Skrlance

    (@seanlance)

    It is working now sory for asking!

    Plugin Support devnihil

    (@devnihil)

    @seanlance You can use the filter wpseo_exclude_from_sitemap_by_post_ids to exclude post or pages from the Yoast SEO sitemap. The filter would be placed in your functions.php file.

    You can exclude by IDs by using the following code in your theme’s functions.php file:

    add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function () {
    	return array( 311, 322 );
    } );

    You’ll need to replace the array items with the ID that you’d like to exclude. Once you place the code and save it on your site, please disable and re-enable the XML sitemap from Yoast SEO -> General -> Features (tab) to clear transient cache.

    We also have more information on this here: https://kb.yoast.com/kb/sitemap-shows-excluded-posts-pages/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove Shop Page from SiteMap’ is closed to new replies.