Skip to content

Instantly share code, notes, and snippets.

@mattpramschufer
Last active January 11, 2017 14:04
Show Gist options
  • Save mattpramschufer/0dcfa8dfd821880f8249ab8ddaa08b80 to your computer and use it in GitHub Desktop.
Save mattpramschufer/0dcfa8dfd821880f8249ab8ddaa08b80 to your computer and use it in GitHub Desktop.
Add Offset to Wordpress RSS Feed
<?php
function rss_pre_get_posts($query) {
if (isset($_GET['days_past']) && is_feed()) {
$query->set('date_query', array(array('after' => $_GET['days_past'] . ' days ago',)));
}
if (isset($_GET['offset']) && is_feed()) {
$query->set('offset', $_GET['offset']);
}
if (isset($_GET['cat']) && is_feed()) {
$query->set('cat', $_GET['cat']);
}
return $query;
}
add_action('pre_get_posts', 'rss_pre_get_posts');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment