Rank Math Sitemap: Leave Out Whole Post Types
Removes entire post types from the Rank Math sitemap index regardless of the sitemap settings screen.
Opens WPIDE on
Code
// Post types to leave out.
$wpide_rm_skip_types = array( 'landing', 'attachment' );
add_filter( 'rank_math/sitemap/exclude_post_type', function ( $exclude, $type ) use ( $wpide_rm_skip_types ) {
return in_array( $type, $wpide_rm_skip_types, true ) ? true : $exclude;
}, 10, 2 );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.