How to delay display a new article in RSS on WordPress

Last updated December 6th, 2023 00:56

Do you need to delay the display of your new WordPress post in the RSS feed? Extending the time it takes for your post to appear in the RSS feed can save you in bad situations. For example, you accidentally publish a post that is not ready. This gives you time to finish the post, correct any mistakes, and add missing parts. In this article, we will look at how to delay the display of a new post in the RSS feed in WordPress.

Why delay the display of a new article in RSS?

Sometimes, you may find yourself in a situation where you publish an article that it contains errors, whether factual or grammatical. This article then spreads the error to all users through RSS readers. You no longer have much chance to modify the content for this part of the readership. With a grammatical error, you could still get away with it. But with a factual error, it could be a problem.

From the above, it is clear that if you create a time delay for publishing an article in the RSS feed. You will gain at least some time to detect and correct such errors.

How to delay the display of a new WordPress post in RSS

To delay the display of a new WordPress post in RSS, you will need a plugin for inserting code snippets into your website content. A code snippet is a short piece of code that can modify the behavior of your WordPress site. Here, I will show you how to use a code snippet. In our case for delay the display of new WordPress posts in RSS.

A very useful plugin in this regard is WPCode. I have written a complete guide on how to work with this plugin here: How to insert custom code in WordPress.

To use the WPCode plugin, simply install and activate it from the WordPress administration interface. To delay the display of a new post in the RSS feed using this plugin, you will need the following code:

				
					function wpb_snippet_publish_later_on_feed( $where ) {
 
    global $wpdb;
 
    if ( is_feed() ) {
        // Timestamp in WP-format.
        $now = gmdate( 'Y-m-d H:i:s' );
 
        // Number of unit to wait
        $wait = '10'; // integer.
 
        // Choose time unit.
        $unit = 'MINUTE'; // MINUTE, HOUR, DAY, WEEK, MONTH, YEAR.
 
        // Add SQL-sytax to default $where. By default 10 minutes.
        $where .= " AND TIMESTAMPDIFF($unit, $wpdb->posts.post_date_gmt, '$now') > $wait ";
    }
 
    return $where;
}
 
add_filter( 'posts_where', 'wpb_snippet_publish_later_on_feed' );

				
			

Variables in code

In the code above, there are two variables that you should primarily focus on. The first variable to pay attention to is the ‘$wait‘ variable, which determines the delay time for the action to take place. In our case, it is set to a value of 10, but you can adjust it to any value you want. The second variable is ‘$unit‘, which specifies the unit of time for the delay. You can set it to minutes, hours, days, etc. So, taking the example as a whole, this snippet will delay the display of new RSS articles by 10 minutes.

Here is an example snippet that will delay the display of new RSS articles by one hour.

				
					function wpb_snippet_publish_later_on_feed( $where ) {
 
    global $wpdb;
 
    if ( is_feed() ) {
        // Timestamp in WP-format.
        $now = gmdate( 'Y-m-d H:i:s' );
 
        // Number of unit to wait
        $wait = '1'; // integer.
 
        // Choose time unit.
        $unit = 'HOUR'; // MINUTE, HOUR, DAY, WEEK, MONTH, YEAR.
 
        // Add SQL-sytax to default $where. By default 10 minutes.
        $where .= " AND TIMESTAMPDIFF($unit, $wpdb->posts.post_date_gmt, '$now') > $wait ";
    }
 
    return $where;
}
 
add_filter( 'posts_where', 'wpb_snippet_publish_later_on_feed' );
				
			
How to delay display a new article in RSS on WordPress
How to delay display a new article in RSS on WordPress

How to delay display a new article in RSS on WordPress – conclusion

By using the code mentioned above and with the help of a plugin for inserting snippets, even a true beginner can manage this functionality. It’s really not complicated at all. We’ve now discussed how to delay the display of new RSS posts in WordPress. So it’s up to you to consider whether this feature would be useful for you as well. Anyone can make mistakes in an article. And it’s always good to have some time to get the factual and grammatical data in order before users view the post.

More content about WordPress

Whole category is here

The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.

Byl pro Vás tento článek užitečný?

Klikni na počet hvězd pro hlasování.

Průměrné hodnocení. 0 / 5. Počet hlasování: 0

Zatím nehodnoceno! Buďte první

Jak užitečný vidíte tento článek.

Sledujte mě na sociálních médiích.

Je mi líto, že pro Vás nebyl článek užitečný.

Jak mohu vylepšit článek?

Řekněte mi, jak jej mohu zlepšit.

newsletter

Subscribe to the Newsletter

Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.

Odebírat
Upozornit na
guest
0 Komentáře/ů
Vložené zpětné vazby.
Zobrazit všechny komentáře.

Pokud mi chcete napsat rychlou zprávu, využije, prosím, níže uvedený
kontaktní formulář. Děkuji.

Další Kontaktní údaje