Exclude external images from Sitemap – How to?

#641317
  • Resolved Sebastian
    Rank Math free

    Hello, I have a very big problem that negatively affects my SEO.
    I am using Rank Math in conjunction with AAWP, an affiliate plugin and have found a huge error.
    Namely, when I embed the products there via shortcode, the sitemap loads correctly, the sitemap then only takes the images that are present in the post. https://aurandus.com/post-sitemap3.xml
    But I have loaded the affiliate products via Gutenberg widget in newer posts. Somehow the images end up in the sitemap, although they are not on my server but are loaded externally. Example: https://aurandus.com/post-sitemap1.xml This sitemap loads extremely slowly because the external images were displayed here. Example: https://aurandus.com/tresor-1934-ring/ says 12 images although there are only 2 on the page. The 10 images come from the plugin. The images have this URL https://m.media-amazon.com/
    I wonder why Rank Math includes external images in the sitemap and how I can prevent this? These images are not in my media library either.
    Thanks a lot!

Viewing 3 replies - 16 through 18 (of 18 total)
  • Hello,

    Sorry for not following up quickly and for any inconvenience that might have been caused due to that. We have been checking this issue on your site today so yes the login could be from our side.

    Can you please check the Sitemap again now? Even though the AAWP images are excluded from the Sitemap, Rank Math was still analyzing them because it gets those images from the content. To fix it I have excluded the AAWP blocks from the Sitemap content by adding following code in your theme’s functions.php file:

    
    add_filter( 'rank_math/sitemap/content_before_parse_html_images', function( $content, $post_id ) {
    	$block_name = 'aawp/aawp-block';
    
        // Create a regular expression pattern to match the block
        $pattern = '/<!--\s*wp:' . preg_quote($block_name, '/') . '.*?\/-->/s';
    
        // Remove the block from the content
        $content = preg_replace($pattern, '', $content);
    
    	return $content;
    }, 10, 2 );
    

    This seems to have fixed the issue. Can you please confirm?

    Hope that helps.

    Seems to work, thank you. If something does not work out, I will get in touch

    Hello,

    We are happy it worked for you.

    We will keep this ticket open until you confirm that your issue is resolved. Let us know if you need any further assistance with this.

    Looking forward to hearing from you.

    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 3 replies - 16 through 18 (of 18 total)

The ticket ‘Exclude external images from Sitemap – How to?’ is closed to new replies.