Filters the response when checking the post for exclusion flags in Google News sitemap context. Passes the post exclusion flag and $post_id; must return true or false.

apply_filters( 'xmlsf_news_excluded', bool[] $exclude, int[] $post_id )

Used in xml-sitemap-feed/views/feed-sitemap-news.php

Parameters (2)

  • $exclude
    (bool) The excluded flag originally fetched by get_post_meta( $post->ID, '_xmlsf_news_exclude', true ) which defaults to false.
  • $post_id
    (int) The current post ID.


  • (bool) true|false

The filter should return a boolean value signifying the exclusion of the current post. Returning true will exclude the post from the Google News sitemap.

Usage example

function my_custom_news_exclusion( $exclude, $post_id ) {
	// Verify the post ID against a predefined array.
	$excluded = array( 210, 5531, 7806 );
	if ( in_array( $post_id, $excluded ) ) {
		return true;

	// Return original status.
	return $exclude;
add_filter( 'xmlsf_news_excluded', 'my_custom_news_exclusion', 10, 2 );


Used byDescription