custodiet ipsos custodes 00357 95141123

mail@thrasos.net

Wordpress: Adding delay between post and rss

wordpress-logo-stacked-rgb

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<pre>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-&gt;posts.post_date_gmt, '$now') &gt; $wait ";
    }
    return $where;
}

add_filter('posts_where', 'delay_post_on_feed');</pre>

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