Publish The Feed Later

Some of you know this problem already, you publish a post and while you are publishing you notice an error. That’s very annoying, the error is in your feed an published to the whole world.

That happened quite often to me, my fellow readers a writing comments so fast, right after publishing, to tell me about some errors I made, it’s unbelievable. So I thought I should create a workaround to have the feed published a little bit later, even 5 minutes can be helpful. Here we go:

WordPress works with a special query, which acts differently depending on the user rights. It is always saved in the variable $where and differently assembled. That means, you can extend it.

If you look at the possibilities of mySQL, there is a function timestampdiff(). I extend the query of WordPress with this function. Note to query the feed before (is_feed()), if not it will be also happening for the classical publishing of posts in your blog.

The following example publishs the post 5 minutes later in your feed:

 * puplish the content in the feed later
 * $where ist default-var in WordPress (wp-includes/query.php)
 * This function an a SQL-syntax
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 = '5'; // integer


		// 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');

If you put the above syntax in your functions.php of your theme, then your feed will be published always 5 minutes later. Of course you can adjust the time, also the units, if you need it in a special case. I probably will add this feature in the next release of my Plugin ©Feed.

Comments are closed.


  1. garaj kapısı

    Thanks for this tip.

    But i dont understand, why u want that publish later?

  2. Alex

    Hey Garaj,

    the reason why you might want to publish later is pretty simple. When you publish your feed, people will get your post with all errors immediately. It takes time before the feed updates, if you update your post, it will show the changes immediately, but your feed will stay the same until the next update, an update period can take hours, which is annoying, if all your readers can read the errors in your feed, even if you had correct it some hours ago. Hope that makes it clear. 🙂

  3. Ozh

    Ola there
    Off topic: could anyone from this site contact me? (I couldn’t find any “Contact” form or link here). I’d like to add your site to
    Thanks in advance

  4. Alex

    Hey Ozh,

    I just sent you an email, glad to be part of your planetozh 🙂

    Thanks a lot, can’t be a better compliment!

  5. Christian Ross

    Thanks for the tip/code. Always find myself finding mistakes minutes after I publish an article.

    Any way to edit a feed once it is already published?

  6. Alex

    You are welcome Christian

  7. Simon

    Hey there Alex sounds like the right hack for me! Though when pasting it like this into my function.php I get errors in my wp-admin and a white stripe on top of my blog design. What could cause that?

  8. Alex

    Hey Simon, can you tell me what exactly does it say in your error.


  9. Simon

    Actually, pasting exactly the same as above into the functions.php I get this on top when I want to log in to the admin back.

    /** * puplish the content in the feed later * $where ist default-var in WordPress (wp-includes/query.php) * This function an a SQL-syntax */ function pulish_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 = '5'; // integer // $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', 'pulish_later_on_feed');

  10. Michael

    Simon, you have to use php tags before and after the code like that:

    //here comes the code

  11. Simon

    Grand Michael I tried that yesterday, good to have the confirmation. Thanks a lot!

  12. RupertGee

    Marvelous hack!

    I can’t count how many times I accidentally broadcast unfinished post.


  13. Alex

    You are welcome Rupert 🙂

  14. yemoonyah

    Okay, I tried to add the code at the end of my functions php and this is what I get when I want to go to my admin:

    Fatal error: Call to undefined function add_filter() in /…/…/public_html/wp-includes/functions.php on line 2928

    can you help?

    Thanks for posting, is exactly what I need!

  15. Michael

    yemoonyah, you have to use the functions.php in your theme folder, not the wp-includes/functions.php.
    If you don’t have a functions.php in your theme folder, create one.

  16. Sjakelien

    OK, I think this mechanism is very close to something I’m looking for. The problem is that I don’t know PHP.
    What I would like to see is the following:
    An algorithm, that, given a specific category, would delay the publishing of a post.
    So, for instance: if the category is “Sports”, the delay would be one day. If the category is “Hot News”, the delay would be zero.
    Is there anyone around here who could write up something for me? Thanks in advance.
    I’ll send you something from the Netherlands…

  17. Frank

    Sjakelien: Yes this is also possible. PLease check this with the conditional tags:
    if ( is_feed() && is_category('6') ) {

  18. Sjakelien

    OK,thanks, but where would I put that, and what would the publication date/time parameter be?

  19. salzano

    awesome! this is exactly what i need. small typo in your function name, btw…

    pulish => publish

  20. Michael

    Thanks salzano! Fixed.

  21. Michael

    Sjakelien, in the same function.

    function publish_later_on_feed($where) {
    if ( is_feed() && is_category('6') ) {

  22. Simon

    Is it possible I’ve got some settings wrong here? I don’t get any feedburner mails/feed anymore since adding this (exact copy) to my functions.php?
    Thank you a lot!

  23. Erik

    I found that when I pasted this into the functions.php file it would cause my RSS feed to no long work. If you went to the URL of the feed there would be a page not found error and feedburner could no longer use the feed.

    I found that once this was code was deleted from the functions.php file everything worked again. I liked the concept of this but if using it is going to cause my feed to be unavailable I will deal with publishing the RSS at the same time.

    Have you encountered any one else with this problem?

  24. Simon

    Yeah Erik, same thing here although the feedburner feed is still there, just with all the items up to when I added the code to the functions.php. Any recommendations?

  25. Frank

    The code works fine and i think you have only a problem in your theme or a problem with other plugins. The function wait 10 minutes and the is the same content in the feed. Feedburner scan the code in different interval with and publish later. Maybe is this a problem with this function.

  26. Erik

    I tried it with the default WordPress theme and it was still causing the same problem. I turned off all of my plug ins and there was still the same problem. It had nothing to do with Feedburner this code caused the feed from WordPress ( to no longer work.

  27. Frank

    I have tested the code under many blogs and i use the code in many live blogs. Do you have correct copy the code in the functions.php of the Theme, with the php-tags?

  28. ookla

    Hey dude.. can you help me?

    My server time (php date): 9:13 AM
    My server time (php gmdate): 5:13 PN
    Wordpress time: 1:13 PM

    How can I change your var _now to make this works with this?


  29. ookla

    fixed.. it was that ‘greater than’ character

  30. AlexPTS

    Why Publish The Feed Later?

  31. Azzam

    @AlexPTS. Answered in a previous comment.

    Do I still need to apply this if I am using feedburner since you mention that is scans in intervals?

  32. Erik

    It just came to my attention that my feed seems to have a delay of 1 message.

    So if I post a message, the message before that one appears in my feed. My readers read my blogposts when they are already dated.

    I neutralized this script and my issue was over. I am going to switch it on later this day just before publishing a new artciel to double check if it really originates from this script.

  33. Ves

    Hey Erik, I’m having the same problem. On the site we work (WP 2.7.1) we’re getting same kind of delay.

  34. erik

    I still have this issue and not sure what is the reason. If i post a message it is not included in the fed directly, even after pinging and a refresh (I use feedburner).

    last time it worked when I changed the time of posting. I do not spend much time testing since it is a smaller blog where this happens.

  35. Sean Turtle

    Thanks very much – really appreciated!

  36. Carlos Reveco

    I create this script to publish rss weekly based on this post.
    Thanks for the idea!
    add this script in your functions.php of your theme.

    * puplish the content in the feed later
    * $where ist default-var in WordPress (wp-includes/query.php)
    * This function an a SQL-syntax

    function publish_weekly_on_feed($where) {
    global $wpdb;

    if ( is_feed() ) {

    $now = gmdate(‘Y-m-d H:i:s’);

    // value for wait; + device
    $wait = ‘1’; // integer
    $device = ‘WEEK’; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR

    $where .= ” AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, ‘$now’) > $wait “;

    $where .= ” OR $day = ‘4’ “; //1 = monday, 2= tuesday …. 7 =sunday
    return $where;

    add_filter(‘posts_where’, ‘publish_weekly_on_feed’);

  37. Andy - The Digitante

    I just tossed this in my function.php but I haven’t published since doing so. We’ll see how it goes tomorrow!


  38. Matt

    How can I delay just one feed. I’d like my main feed to publish immediately, but I’d like to have another feed that I can provide to my syndication partners that has a delay. Any suggestions?

  39. Joe

    I would also like to know how to delay just one feed, while leaving other feeds not delayed. Or how to create a special xml page that displays the delayed version of the feed.

  40. MIDD

    Our website uses wordpress as a platform. We tested our RSS and there’s a whole month delays. So the blog post i’ll get on my outlook or google reader would be the post last month rather than the latest one. Where could the problem lie?

    Is it the same principle as this? I mean delaying 5 minutes. Could it be possible that rather than delaying 5 minutes, ours is delayed in 30 days?

  41. Ice

    I’ve tried your function…works great!

    Now…how can I add to the function a filter that excludes posts that have already been published? Sometimes I update a post and I don’t want these updated posts going back through the feed.

    I’m thinking I could use a custom field to mark the post but I just don’t know how to write the query.


  42. Edi at web

    Thanks for this guide. But if i want that google index content fast i ping rss feed. One real scenarion:
    – aggregator post in blog
    – blog generate feed from posts
    – i ping by cron job generated rss feed

    Is simple – if feed is generated after 5 minutes, just content will be indexed after 5 minutes. In this way you must create 2 feeds – one public that is with 5 or better with 15 minutes delay and one private that you will use only to ping google to index .

23 pingbacks

  1. Setting Your Feed to Delay Being Published | WordPress Hacks Log
  2. Links am Montag - Doku-Hotline - Birgit Grossmann über Texte, Technik und technische Dokumentation
  3. 10 Useful RSS Hacks For WordPress | Developer's Toolbox | Smashing Magazine
  4. Kontroller hvornår din blogartikel bliver synlig i dit RSS-feed
  5. Deferred RSS: отложенная публикация RSS-фидов | Ars Longa, Vita Brevis
  6. Publish The Feed Later
  7. 10个优化WordPress RSS Feed的技巧(1) |     理处言语然自
  8. Delay RSS Publishing by 5 minutes in WordPress »
  9. Противодействие плагиату RSS | AlexNote
  10. Putting a Delay on your RSS Submissions | 4 Hour Followers
  11. How to: Control when your posts are available via rss
  12. Pallian Creative » 5 Must-Have Wordpress Plugins for 2009
  13. Delay Your WordPress RSS Feeds to Catch Errors In Time :: TinyHacker
  14. Toma el control de los RSS de tu Wordpress | aNieto2K
  15. Fördröj publiceringen till ditt RSS-flöde | Andreas Karman
  16. Противодействие плагиату RSS (Wordpress) | Help For Web Developers
  17. RSS feed heeft vertraging van 1 bericht —
  18. Details on the 10 Most Helpful Wordpress Design Blogs | Arbenting
  19. 10个实用的WordPress RSS技巧 | 帕兰映像
  20. 不要轻易按下“发布”按钮 - Kangzj
  21. Publish The Feed Later « Weblog Tools Collection
  22. Ten WordPress Tips to Take You to the Next Level | LonePlacebo
  23. WordPress: Steuern, wann die Beiträge via RSS verfügbar sind | Dackworld