WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Include subsites in main blog's sitemap on multisite network (4 posts)

  1. PaulMighty
    Member
    Posted 1 year ago #

    Hello!

    I am running a multisite/network install of WordPress using the Yoast WordPress SEO plugin. I'm wondering if it is possible to generate links to subsite sitemaps from the main blog/site sitemap? This way the subsites would be included with all the other category and post types like this in the main blog/site's sitemap_index.xml:

    http://www.domain.com/post-sitemap.xml
    http://www.domain.com/page-sitemap.xml
    http://www.domain.com/category-sitemap.xml
    http://www.domain.com/subsite-1/sitemap_index.xml
    http://www.domain.com/subsite-2/sitemap_index.xml
    http://www.domain.com/subsite-3/sitemap_index.xml

    Thanks!
    -Paul

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. daffscat
    Member
    Posted 1 year ago #

    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!

  3. PaulMighty
    Member
    Posted 1 year ago #

    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

  4. PaulMighty
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic