Are you looking for a way to easily delay your posts to RSS feed? Delaying can help in fixing the mistakes before your posts appear on the feed. While there’s probably a plugin for this, we have created a quick code snippet that you can use to delay RSS feed in WordPress.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
function publish_later_on_feed($where) { global $wpdb; if ( is_feed() ) { $now = gmdate('Y-m-d H:i:s'); // value for wait; + device $wait = '5'; // integer $device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR $where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait "; } return $where; } add_filter('posts_where', 'publish_later_on_feed');
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 15 best content marketing tools and how to create a custom user registration form in WordPress.
Can I use this to delay the posting of the topic feed from bbpress?
Thanks!