Skip to content

Instantly share code, notes, and snippets.

@rickrduncan
Created May 28, 2014 11:22
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 rickrduncan/f730d55d6a2e4575dda6 to your computer and use it in GitHub Desktop.
Save rickrduncan/f730d55d6a2e4575dda6 to your computer and use it in GitHub Desktop.
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