Delay RSS Feed publishing

You hit “Publish” instead of “Save Draft” or “Preview” on the post you are working on and have to hurridly edit it and put it back into draft status. Or you may notice some glaring error that needs correcting. What this snippet does is delay the updating of your RSS Feed, add the following to your theme’s functions.php file and it will be delayed by 7 minutes:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
* publish the content in the feed later
* $where ist default-var in WordPress (wp-includes/query.php)
* This function an a SQL-syntax
*/
 
function publish_later_on_feed($where) {
global $wpdb;
 
if ( is_feed() ) {
// timestamp in WP-format
$now = gmdate('Y-m-d H:i:s');
 
// value for wait; + device
$wait = '7'; // 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', 'publish_later_on_feed');
/*
* publish the content in the feed later
* $where ist default-var in WordPress (wp-includes/query.php)
* This function an a SQL-syntax
*/

function publish_later_on_feed($where) {
global $wpdb;

if ( is_feed() ) {
// timestamp in WP-format
$now = gmdate('Y-m-d H:i:s');

// value for wait; + device
$wait = '7'; // 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', 'publish_later_on_feed');

Source: wpengineer

Related Posts:

  • Display Post Thumbnails in the Feed
    Lots of themes these days make use of post thumbnails or featured images but these aren’t included in your RSS feed by default. To add them in, add the following to your theme's functions.php file./...

Tags: , , ,

24.Sep.11 Tips


You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.

Leave a Comment

:)