Skip to content

Instantly share code, notes, and snippets.

@davebonds
Last active October 3, 2018 04:45
Show Gist options
  • Save davebonds/f69f6c95751084284246454068ec618d to your computer and use it in GitHub Desktop.
Save davebonds/f69f6c95751084284246454068ec618d to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment