-
Harris a publié un message
Comment supprimer les index de types d'articles spécifiques du sitemap_index.xml de Yoast ?
I used Yoast’s API to create a custom XML sitemap that combines all of my website pages and a few other post types into one. I do the same thing for translated pages so that they are in their own sitemap.
I want to remove the Yoast-created XML sitemaps from the sitemap_index.xml so only my custom sitemap is there. I cannot find any references to how to accomplish this. I tried using the
wpseo_sitemap_exclude_post_type
filter to remove the post types for the other sitemaps, but doing so removed my custom sitemap from the sitemap index as well (since it is comprised of the same post types that I excluded).Is there any way to do this?
stackoverflow.com
Stack Overflow | La plus grande communauté en ligne de développeurs au monde
Martin-
Vous pouvez utiliser le code ci-dessous dans le fichier functions.php :
function yoast_sitemap_exclude_post_type_sp( $value, $post_type ) {
// supprimer post_type : product, post, page
if ( $post_type == 'product' || $post_type == 'post' || $post_type == 'page') {
retourner vrai ;
}
}
add_filter( ‘wpseo_sitemap_exclude_post_type’, ‘yoast_sitemap_exclude_post_type_sp’, 10, 2 );
[enter image description here][1]
-
@ava-martin How does this solve the issue? Please explain what you’ve you changed to address the issue.
Also, I mentioned in my description that I already tried using the wpseo_sitemap_exclude_post_type filter to exclude the “page” and “people” post types, but doing so caused my custom sitemaps to disappear from the index as well. 😅
-
-