• Resolved WP Explorer

    (@kriswen)


    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:00

    Q2 ) 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)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello @kriswen

    Thanks for reaching out regarding your sitemap. First, your Yoast SEO-generated XML sitemap index should be accessible at /sitemap_index.xml/.

    You are correct about the post-type names, and the respective sitemaps should be accessible as so.

    I can’t review the code but you can exclude sitemaps from the index based on post types in WordPress > Yoast SEO > Settings > Content Types. For each post type, toggle the button to turn OFF the feature to show it in search results

    Thread Starter WP Explorer

    (@kriswen)

    Thanks for pointing out the setting section, I was able to disabled some of them from there!

    However, there are still some types shown below in the sitemap_index.xml that are not presented in the setting, how do I disable those?

    https://mydomain.wpengine.com/docs-sitemap.xml 2023-02-07 20:18 +00:00
    https://mydomain.wpengine.com/category-sitemap.xml 2023-02-06 13:03 +00:00
    https://mydomain.wpengine.com/event_listing_category-sitemap.xml 2023-03-10 17:23 +00:00
    https://mydomain.wpengine.com/event_listing_type-sitemap.xml 2023-03-10 17:23 +00:00
    https://mydomain.wpengine.com/doc_category-sitemap.xml 2023-02-07 20:18 +00:00
    https://mydomain.wpengine.com/doc_tag-sitemap.xml 2023-02-07 20:18 +00:00


    Plugin Support Maybellyne

    (@maybellyne)

    Thanks for the feedback, @kriswen

    Sitemaps generated for docs-sitemap, category, event_listing_category, event_listing_type, doc_category and doc_tag are still present because they’re yet to be disabled. Those are taxonomies, so you’d find them in WordPress > Yoast SEO > Settings > Categories & tags.

    Do let me know how it goes.

    Thread Starter WP Explorer

    (@kriswen)

    @maybellyne Thank you for the guide, it’s removed now.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘exclude multiple post type from sitemap’ is closed to new replies.