Wordpress - Scheduling Posts for RSS


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. function publish_later_on_feed($where) {
  2. global $wpdb;
  3.  
  4. if(is_feed()) {
  5. // timestamp in WP-format
  6. $now = gmdate('Y-m-d H:i:s');
  7.  
  8. // value for wait; + device
  9. $wait = '5'; // integer
  10.  
  11. // http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
  12. $device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
  13.  
  14. // add SQL-sytax to default $where
  15. $where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
  16. }
  17.  
  18. return $where;
  19. }
  20.  
  21. add_filter('posts_where', 'publish_later_on_feed');

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.