Home / RSS Feeds / Delay Posts in RSS Feeds
Duplicate Snippet

Embed Snippet on Your Site

Delay Posts in RSS Feeds

Add a delay before published posts show up in the RSS feeds.

800+
Code Preview
php
<?php
function wpcode_snippet_publish_later_on_feed( $where ) {
	global $wpdb;
	if ( is_feed() ) {
		// Timestamp in WP-format.
		$now = gmdate( 'Y-m-d H:i:s' );
		// Number of unit to wait
		$wait = '10'; // integer.
		// Choose time unit.
		$unit = 'MINUTE'; // MINUTE, HOUR, DAY, WEEK, MONTH, YEAR.
		// Add SQL-sytax to default $where. By default 10 minutes.
		$where .= " AND TIMESTAMPDIFF($unit, $wpdb->posts.post_date_gmt, '$now') > $wait ";
	}
	return $where;
}
add_filter( 'posts_where', 'wpcode_snippet_publish_later_on_feed' );

Comments

Add a Comment