Shoora
10/3/2018 - 4:45 AM

Add IDX sitemap to Yoast SEO sitemap

Add IDX sitemap to Yoast SEO sitemap

<?php
/**
 * Adds IDX sitemap URLs to Yoast's sitemap_index.xml
 * Get your individual sitemap URLs by viewing the source of your primary sitemap URL.
 * To manually refresh your sitemaps, deactivate sitemaps and reactivate.
 * From: https://kb.yoast.com/kb/add-external-sitemap-to-index/
 */
add_filter( 'wpseo_sitemap_index', 'add_idx_sitemap' );
function add_idx_sitemap() {
	$idx_sitemap = '
	<sitemap>
	    <loc>http://subdomain.yourdomain.com/idx/sitemap/links/somerandom1234</loc>
	    <lastmod>2017-08-23T23:12:27+00:00</lastmod>
    </sitemap>
    <sitemap>
	    <loc>http://subdomain.yourdomain.com/idx/sitemap/savedlinks/somerandom1234</loc>
	    <lastmod>2017-08-23T23:12:27+00:00</lastmod>
    </sitemap>
    <sitemap>
	    <loc>http://subdomain.yourdomain.com/idx/sitemap/cities/a000/somerandom1234</loc>
	    <lastmod>2017-08-23T23:12:27+00:00</lastmod>
    </sitemap>
    <sitemap>
	    <loc>http://subdomain.yourdomain.com/idx/sitemap/counties/a000/somerandom1234</loc>
	    <lastmod>2017-08-23T23:12:27+00:00</lastmod>
    </sitemap>
    <sitemap>
	    <loc>http://subdomain.yourdomain.com/idx/sitemap/zipcodes/a000/somerandom1234</loc>
	    <lastmod>2017-08-23T23:12:27+00:00</lastmod>
    </sitemap>
    <sitemap>
	    <loc>http://subdomain.yourdomain.com/idx/sitemap/prices/somerandom1234</loc>
	    <lastmod>2017-08-23T23:12:27+00:00</lastmod>
    </sitemap>';
	return $idx_sitemap;
}