MainWP Community

Change the URL for images in the sitemap if using a CDN in Yoast SEO

Change the URL for images in the sitemap if using a CDN CNAME URL on child sites running Yoast SEO.

Snippet Type

Execute on Child Sites

Snippet

function wpseo_cdn_filter( $uri ) {
  return str_replace( 'http://example.com', 'http://cdn.example.com', $uri );
}
add_filter( 'wpseo_xml_sitemap_img_src', 'wpseo_cdn_filter' );
1 Like

Replace the URL with the correct CDN url.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.