Skip to content

Instantly share code, notes, and snippets.

@mariadanieldeepak
Created June 30, 2018 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariadanieldeepak/95544861e1e4a3dc68b0330bf06aed42 to your computer and use it in GitHub Desktop.
Save mariadanieldeepak/95544861e1e4a3dc68b0330bf06aed42 to your computer and use it in GitHub Desktop.
Excludes Post IDs from Jetpack news sitemap
/**
* 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