Last active
January 11, 2017 14:04
-
-
Save mattpramschufer/0dcfa8dfd821880f8249ab8ddaa08b80 to your computer and use it in GitHub Desktop.
Add Offset to Wordpress RSS Feed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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