Return to Snippet

Revision: 21997
at December 28, 2009 11:36 by mdrisser


Initial Code
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 = '5'; // 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');

Initial URL
http://webdesignledger.com/tips/13-useful-code-snippets-for-wordpress-development

Initial Description
From Web Design Ledger "13 Useful Code Snippets for WordPress Development"

Initial Title
Wordpress - Scheduling Posts for RSS

Initial Tags
wordpress

Initial Language
PHP