exclude multiple post type from sitemap
-
I followed this doc (https://developer.yoast.com/features/xml-sitemaps/api/#exclude-specific-posts) to exclude single post type from the sitemap index file.
Q1) Here is the list from my https://mydomain.com/sitemap.xml. How do I confirm the ‘post type’ name? I assume it would be “poll”, “da_image”, “category”, etc?
https://mydomain.com/post-sitemap.xml 2023-02-06 13:03 +00:00 https://mydomain.com/page-sitemap.xml 2023-03-01 20:51 +00:00 https://mydomain.com/event_listing-sitemap.xml 2023-02-27 16:39 +00:00 https://mydomain.com/docs-sitemap.xml 2023-02-07 20:18 +00:00 https://mydomain.com/poll-sitemap.xml https://mydomain.com/da_image-sitemap.xml 2022-11-17 13:02 +00:00 https://mydomain.com/category-sitemap.xml 2023-02-06 13:03 +00:00 https://mydomain.com/event_listing_category-sitemap.xml 2023-03-01 23:35 +00:00 https://mydomain.com/event_listing_type-sitemap.xml 2023-03-01 23:35 +00:00 https://mydomain.com/doc_category-sitemap.xml 2023-02-07 20:18 +00:00 https://mydomain.com/doc_tag-sitemap.xml 2023-02-07 20:18 +00:00Q2 ) However, i’m not sure how to exclude more than one post type. When I write the code like below, but the result does not exclude those post types
function sitemap_exclude_post_type( $excluded, $post_type ) { return $post_type === 'poll'; } function sitemap_exclude_post_type_two( $excluded, $post_type ) { return $post_type === 'category'; } add_filter( 'wpseo_sitemap_exclude_post_type', 'sitemap_exclude_post_type', 10, 2 ); add_filter( 'wpseo_sitemap_exclude_post_type_two', 'sitemap_exclude_post_type', 10, 2 );
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘exclude multiple post type from sitemap’ is closed to new replies.