WordPress.org

Support

Support » Plugins and Hacks » [Plugin: WordPress SEO by Yoast] Include subsites in main blog's sitemap on multisite network

[Plugin: WordPress SEO by Yoast] Include subsites in main blog's sitemap on multisite network

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

    I’m looking for the same information. Any news or thoughts since your last post?.

    Ours subsites are independent but fully integrate into our main network (same header, same main menu, same footer, …). For us it makes sense that subsites also appear as part of our main blogs and be included from the main blog/site sitemap.

    I am not an expert in sitemap, but the way I imagine web crawler works is that when looking for a sitemap (or robots.txt), it first looks into the web server’s root directory, then follows directives (either sitemap.xml or robots.txt). So without explicit directive (http://www.domain.com/subsite-1/sitemap_index.xml) from the main blog sitemap.xml to look at for subsites sitemap.xml , how a web crawler will find it ?.

    Could someone please enlighten me ?

    Thanks!

    I was snooping around in the plugin code, which lead me to finding these two links, which may provide clues to adding custom sitemap entries:
    http://wordpress.org/support/topic/plugin-wordpress-seo-by-yoast-include-non-wordpress-pages-in-sitemap
    http://wordpress.org/support/topic/news-sitemap-gives-an-error-in-google-if-no-posts-are-chosen

    On line 213 of wordpress-seo/inc/class-sitemaps.php you’ll find:
    $this->sitemap .= apply_filters( 'wpseo_sitemap_index', '' );

    Seeing this and looking at link #2 above, I believe we can hook into the sitemap by creating an array and passing it by…
    add_filter( 'wpseo_sitemap_index', array( $this, 'add_to_index' ) );

    -Paul

    Successfully tested by adding the following to functions.php:

    function add_sitemap_custom_items(){
    	$sitemap_custom_items = '<sitemap>
    		<loc>http://www.website.com/custom-page-1/</loc>
    		<lastmod>2012-12-18T23:12:27+00:00</lastmod>
    	</sitemap>
    	<sitemap>
    		<loc>http://www.website.com/custom-page-2/</loc>
    		<lastmod>2012-12-18T23:12:27+00:00</lastmod>
    	</sitemap>
    	<sitemap>
    		<loc>http://www.website.com/custom-page-3/</loc>
    		<lastmod>2012-12-18T23:12:27+00:00</lastmod>
    	</sitemap>';
    
    	return $sitemap_custom_items;
    }
    add_filter( 'wpseo_sitemap_index', 'add_sitemap_custom_items' );

    Now, if only I knew of a way to filter OUT specific items that are auto-generated by the plugin in addition to using the plugin’s options to exclude Post Types and Taxonomies. It would be great if these were options from within the plugin’s admin page, but it’s already an incredibly helpful plugin, so I’m not complaining.

    -Paul

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WordPress SEO by Yoast] Include subsites in main blog's sitemap on multisite network’ is closed to new replies.