Last active
October 17, 2016 07:30
-
-
Save edalis/901cb474c4927777ff7da00d053431e2 to your computer and use it in GitHub Desktop.
WP: Delay Posts in RSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.wpbeginner.com/wp-tutorials/how-to-delay-posts-from-appearing-in-wordpress-rss-feed/ | |
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 = '10'; // 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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment