Created
March 29, 2023 09:25
-
-
Save damiencarbery/870ae9f3392ab5b029fe12b4ed71fd2b to your computer and use it in GitHub Desktop.
Sitemap - exclude a custom post type
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 | |
/* | |
Plugin Name: Sitemap - exclude a custom post type | |
Plugin URI: https://wpza.net/how-to-exclude-post-types-from-wp-sitemap-xml-in-wordpress/ | |
Description: Exclude a specific custom post type from the WordPress sitemaps. | |
Version: 0.1 | |
Author: Damien Carbery | |
Author URI: https://www.damiencarbery.com | |
*/ | |
function dcwd_remove_cpt_from_wp_sitemap( $post_types ) { | |
unset( $post_types['cust_post_type'] ); | |
return $post_types; | |
} | |
add_filter( 'wp_sitemaps_post_types', 'dcwd_remove_cpt_from_wp_sitemap' ); | |
// Can also exclude specific posts: https://wpza.net/removing-specific-posts-from-wp-sitemap-xml-in-wordpress/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment