Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Small script to place in child theme functions.php file to delay the publishing of a new RSS feed file.
<?php
//* Do NOT include the opening php tag
//* Delay the adding of new content to the WordPress RSS feed
function b3m_delay_publish_rss_feed($where) {
global $wpdb;
if ( is_feed() ) {
// timestamp in WP-format
$now = gmdate( 'Y-m-d H:i:s' );
//* value for wait; + device
$wait = '15'; //integer
//* http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
$device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
//* add SQL-sytax to default $where
$where.=" AND TIMESTAMPDIFF( $device, $wpdb->posts.post_date_gmt, '$now' ) > $wait ";
}
return $where;
}
add_filter('posts_where', 'b3m_delay_publish_rss_feed');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.