Recently, one of our readers asked us if it was possible to delay the appearance of an article in the WordPress RSS feed? Delaying the appearance of an article in the RSS feed, can save you from accidental publication and fight against those who copy your content (you will have had priority in the publication).
In this tutorial, we will show you how to delay the appearance of articles on WordPress.
Why delay the appearance of articles on WordPress?
Sometimes you may end up with poor grammar or spelling in your article. The error will be present and sent to your RSS subscribers. If you have a newsletter, then these people will also receive them.
By adding a delay between your RSS feed and your live site, you have a little time to catch the error and fix it.
RSS feeds are also used by auto-blogs. They use it to monitor your content and copy your articles as soon as they appear live.
If you have a new website with little authority, in some cases, these auto-blogs will manage to beat you in search engine rankings.
By delaying the appearance of an article, you can give search engines time to analyze and index your content first.
So we'll see how to easily delay the appearance of articles on your RSS feed.
How to delay the appearance of an article in the RSS feed
This method requires you to add little code in WordPress. If this is your first time, you can always check out our plugin creation tutorial. But this is not the case, you can contact us, we will work for you.
You must add the following code to the file functions.php Of your theme or add it to your plugin.
function publish_later_on_feed ($ where) {global $ wpdb; if (is_feed ()) {// timestamp in WP-format $ now = gmdate ('Ymd H: i: s'); // value for wait; + device $ wait = '10'; // 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');
This code checks if a WordPress RSS feed is requested. After that, it sets the current time and the time you want to add as the interval between the item's original date and the current time.
After that, it adds the timestamp difference in the WHERE clause to the original query. The original request will now only return items where the time difference is greater than the waiting time.
In this code, we have defined 10 minutes how long to wait. Feel free to change that by what you want.
We hope this tutorial will help you delay the appearance of your articles in the RSS feed. Feel free to leave a comment if you do not understand a point.