WordPress tutorials: Delay RSS feed

Wpsnipp – Adding this to your functions.php file will delay your posts to RSS feed. This is a good way to fix mistakes before they are published to your feed.WordPress works with a special query, which acts differently depending on the user rights. It is always saved in the variable $where and differently assembled. That means, you can extend it.

 

 

function publish_later_on_feed($where) {
global $wpdb;
if ( is_feed() ) {
$now = gmdate('Y-m-d H:i:s');
// value for wait; + device
$wait = '5'; // integer
$device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
$where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
}
return $where;
}
add_filter('posts_where', 'publish_later_on_feed');

Be Sociable, Share!

Leave a comment