Thrasos Website

Sometimes I write about tech and code, and sometimes I don't.

Menu
  • Home
  • About
Menu

WordPress: Adding delay between post and rss

Posted on October 28, 2011May 14, 2013 by thrasos

The case here when you have a wordpress website and you’ve made a post and immediately realized that there is an error or some sort of mistake. The default setting here is not forgiving and the RSS feed has been pushed to all your readers. There is a hack to override this and add a custom delay.

Open functions.php on your theme editor

[cc lang=”php”]

function delay_post_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, this refers to minutes for the delay

		$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', 'delay_post_on_feed');

[/cc]

Posting stuff that helped me and so I don’t forget :-)

Category: blog

Post navigation

← glfx.js
WordPress: Adding stuff to your RSS feed →

You can say something here... Cancel reply

  • GitHub
  • LinkedIn
  • Twitter
  • Telegram
  • Cleaning up VCARD contacts without a phone.January 29, 2023
  • Docker Compose Notes #2December 15, 2022
  • Docker Notes #1December 14, 2022
  • A.I generated poem in GreekDecember 11, 2022
  • A.I. Generated ArtDecember 10, 2022
  • A.I. generated art.December 9, 2022
  • MailCow, simple html in maindomainSeptember 10, 2022
  • CamouflageFebruary 1, 2022
  • Kerkhoffs principleNovember 16, 2020
  • ASCII ARTAugust 13, 2020
© 2023 Thrasos Website