Exclude terms from sitemap programmatically

#200709
  • Resolved Alex
    Rank Math free

    Hi, I am looking for filter to exclude terms from being in the sitemap programmatically instead of using the settings page manually.

    Similar to ‘rank_math/sitemap/posts_to_exclude’. Can’t seem to find anything in the documentation.

    Thank you for your help in advance.

    Alex

Viewing 3 replies - 1 through 3 (of 3 total)
  • Brian
    Rank Math free

    Hello,

    Thank you for contacting Rank Math today.

    Well, not sure if you are aware that we have a method to exclude specific terms from your sitemap by using the following option in Rank Math > Sitemap > General:
    terms

    As an alternative, you can try and customize the following function to target your terms.

    /**
     * Filter decision if a post type is excluded from the XML sitemap.
     *
     * @param bool   $exclude Default false.
     * @param string $type    Post type name.
     */
    add_filter( 'rank_math/sitemap/exclude_post_type', function( $exclude, $type ){
    	return $exclude;
    }, 10, 2 );

    Looking forward to helping you. Thank you.

    Alex
    Rank Math free

    Hi,

    I am trying to exclude specific terms from custom taxonomies. The filters ‘rank_math/sitemap/exclude_post_type’ and ‘rank_math/sitemap/posts_to_exclude’ seems to work only for custom post types and not custom taxonomies.

    Do you know of any other filters that may work with the terms from a custom taxonomy. Similar to Rank Math > Sitemap > General: Exclude Terms settings but as a filter?

    Thanks

    Anas
    Rank Math business

    Hello,

    You can modify this filter to exclude taxonomies.

    /**
     * Filter decision if taxonomy is excluded from the XML sitemap.
     *
     * @param bool   $exclude Default false.
     * @param string $type    Taxonomy name.
     */
    add_filter( 'rank_math/sitemap/exclude_taxonomy', function( $exclude, $type ){
    	return $exclude;
    }, 10, 2 );

    I hope this helps. Looking forward to helping you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Exclude terms from sitemap programmatically’ is closed to new replies.