Disable Sitemap Creation in WordPress SEO

This is a guest post by Ronald Huereca (@ronalfy):

By default, WordPress SEO will create XML sitemaps for custom post types with the public setting set to false. In my opinion, this is incorrect behavior. Here is a code snippet to disable sitemap creation for all non-public post types:

add_filter( 'wpseo_sitemap_exclude_post_type', 'exclude_sitemaps_yoast', 11, 2 );

function exclude_sitemaps_yoast( $exclude = false, $post_type ) {
	$post_type_object = get_post_type_object( $post_type );

	if ( $post_type_object->public === false )
		return true;

	return $exclude;
}

Use Contact Form 7 to collect business leads and enquiries? I created Storage for Contact Form 7 plugin which stores them safely in WordPress database.

Get it now for only $18 →

Leave a Reply