Created
September 7, 2016 08:45
-
-
Save octavian-filipciuc-work/8297a7ef2ae53a56850676967a149066 to your computer and use it in GitHub Desktop.
Delaying Posts in WordPress RSS Feed
This file contains hidden or 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
| 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