Created
June 30, 2018 08:48
-
-
Save mariadanieldeepak/95544861e1e4a3dc68b0330bf06aed42 to your computer and use it in GitHub Desktop.
Excludes Post IDs from Jetpack news 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
/** | |
* Excludes Post ID from Jetpack's news sitemap. | |
* | |
* @param bool $skip | |
* @param WP_Post $post | |
* | |
* @return bool | |
*/ | |
function jpc_exclude_post_from_news_sitemap( $skip, $post ) { | |
if ( ! $post instanceof WP_Post ) { | |
return $skip; | |
} | |
// Make sure you've PHP 5.4 | |
$excluded_post_ids = [9999, 9998]; | |
if ( in_array( $post->ID, $excluded_post_ids, true ) ) { | |
$skip = false; | |
} | |
return $skip; | |
} | |
add_filter( 'jetpack_sitemap_news_skip_post', 'jpc_exclude_post_from_news_sitemap', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment