Open Nikschavan opened 6 years ago
I just came across this looking for a solution, and decided to share my own.
I put the following in my theme's functions.php:
// Hide unlisted posts from sitemap.xml in Yeost SEO // Add this to your theme's functions.php // See: https://kb.yoast.com/kb/sitemap-shows-excluded-posts-pages/ add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function () { $hidden_posts = get_option( 'unlist_posts', array() ); return $hidden_posts; } );
Hope that helps others :)
Works, thank you
If you use AIOSEO this will do the equivalent.
add_filter( 'aioseo_sitemap_exclude_posts', 'aioseo_sitemap_filter_excluded_posts', 10, 2);
function aioseo_sitemap_filter_excluded_posts( $ids, $type ) {
$hidden_posts = get_option( 'unlist_posts', array() );
return $hidden_posts;
}
I just came across this looking for a solution, and decided to share my own.
I put the following in my theme's functions.php:
Hope that helps others :)