SEO PHP Intermediate

Delay Posts in the RSS Feed

Hold new posts out of your RSS feed for 10 minutes after publishing, so you have time to fix mistakes before feed readers and scrapers grab them.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 8 lines
add_filter( 'posts_where', function ( string $where, WP_Query $query ): string {
	if ( $query->is_main_query() && $query->is_feed() ) {
		global $wpdb;
		$cutoff = gmdate( 'Y-m-d H:i:s', time() - 10 * MINUTE_IN_SECONDS );
		$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date_gmt <= %s", $cutoff );
	}
	return $where;
}, 10, 2 );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

The moment you publish, feed readers, email newsletter tools and content scrapers can pick up your post. If you spot a typo a minute later, it’s already gone out. This snippet gives you a 10-minute grace period.

How it works

The posts_where filter adds a condition to the feed’s database query: only include posts published more than 10 minutes ago, compared in UTC. Your site and archive pages show new posts straight away; only feeds wait.

Things to watch

  • Services that send RSS-to-email campaigns will send slightly later.
  • Change 10 to suit how quickly you usually catch mistakes.

How to test it

Publish a post and open /feed/ straight away. The post shouldn’t be there yet; after 10 minutes it should.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only