I need to have just one language in my sitemap, the default language, how?

#576864
  • Resolved Anonymous
    Rank Math free

    I have a multilanguage website build with WMPL. It’s going to be a webshop with over a 100.000 products. I have the product pages in two languages but I only want the products of my default language in my sitemap (I want to keep the file load limited, the second language doesn’t need to be listed in search results) How do I do this? Can I rule out a directory maybe?

Viewing 1 replies (of 1 total)
  • Nigel
    Rank Math business

    Hello,

    Thank you for contacting Rank Math for help with removing translated URLs from your product sitemap. You can use the following filter to remove English urls from your product sitemap:

    
    
    add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ){
    	$post_id = $object->ID;
    	if ( get_post_type( $post_id ) === 'product' && (strpos( $url['loc'], '/en/' ) !== false)) {
    		return false;
    	}
    	return $url;
    }, 10, 3 );
    
    

    You can follow this guide for how to add filters to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps. Please let us know if you have questions.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘I need to have just one language in my sitemap, the default language, how?’ is closed to new replies.