Last active
February 10, 2022 21:03
-
-
Save brandonkramer/5694c5e5fdcd9d4e9c9ae63ef869af41 to your computer and use it in GitHub Desktop.
A short snippet using the Yoast filter to exclude post types from the Yoast Sitemap.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wpseo_sitemap_exclude_post_type', 'your_prefix_exclude_cpt_from_sitemap', 10, 2 ); | |
function your_prefix_exclude_cpt_from_sitemap( $value, $post_type ) { | |
$post_types_to_exclude = [ | |
'post_type_one', | |
'post_type_two' | |
]; | |
if ( in_array($post_type, $post_types_to_exclude) ) { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment