Have you ever written a post then hit the publish button only to discover you missed a typo? I've done it a few times even after proofreading my copy. Of course you can always edit the post but the problem is your RSS feed has already been published and sent out. You can't edit that and it will take some time for the caches of the various feed services to clear and reflect your edit. I'll show you how to avoid this problem by adding a simple delay so that your blog does not immediately publish your feed.
In a plain text editor such as Notepad, open your theme's functions.php and add the following ...
//delay feed publishing
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 = 'x'; // 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');
What we have done is add a filter to the publish_later_on_feed function so that your feed is not published at the same time your post is. You can adjust the time delay to anything you want. Look for the line,
$wait = 'x'; // integer and change x accordingly. For instance, if you wanted a 30 minute delay that line would look like,
$wait = '30'; // integer
Thank you for your tip. I really need a way to delay the publishing of my feeds and let me try your solution.
Hi Siju. Let me know if it works for.
That's interesting. But my question is how to publish it instantly? It takes hours in my blog.
I tried to find such code on Function.php, but nothing found. Can you help me?
It should publish instantly. If it doesn't, then something may be interfering. That could be difficult to troubleshoot. Perhaps a plugin conflict?
Thanks for the reply. I have installed a few plug-ins only - W3 Total cache, feedburner, SEO pack and WordPress backup. Any idea?
Hi techtrickz.
I've not encountered this before. It could be one of those cache plugins but I doubt it. One thing to remember, when you publish a post, WordPress publishes it immediately but that doesn't necessarily mean feed readers will pull it in immediately. All feed readers, both desktop and web-based, pull in feeds according to a schedule. I see you are using Feedburner. As an experiment you could try using their "PingShot" service. You'll find it under Publicize > PingShot.
You're right, it is cache plugin (I think so). Few days back I switched to Hyper Cache from W3 Total Cache, now there is no such delay.
I think it may be because of some configuration error with W3 Total cache.Thanks for your reply.
Glad you got it sorted out. As well, thanks for the update.