25% off ProSNIPC25OFF

Delay Posts in RSS Feed

Withholds recently published posts from the RSS feed for a configurable number of hours to discourage content scraping.

PHPby SnipCraft
php
<?php
add_filter( 'posts_where', 'scseed_delay_rss_feed' );
if ( ! function_exists( 'scseed_delay_rss_feed' ) ) {
    function scseed_delay_rss_feed( $where ) {
        if ( ! is_feed() ) {
            return $where;
        }
        // Delay posts from appearing in the feed for this many hours.
        $delay_hours = 6;
        $cutoff = gmdate( 'Y-m-d H:i:s', time() - ( $delay_hours * HOUR_IN_SECONDS ) );
        $where .= " AND post_date_gmt < '" . esc_sql( $cutoff ) . "'";
        return $where;
    }
}
#content#feed#rss#scraping#security