Skip to content

Instantly share code, notes, and snippets.

@larodiel
Created November 13, 2023 11:50
Show Gist options
  • Save larodiel/92f92e809a121f824ebcae697bbf3d47 to your computer and use it in GitHub Desktop.
Save larodiel/92f92e809a121f824ebcae697bbf3d47 to your computer and use it in GitHub Desktop.
Limit Wordpress RSS Items using parameters
<?php
add_action('pre_get_posts', function($query) {
if ($query->is_feed() && filter_input(INPUT_GET, 'count', FILTER_VALIDATE_INT) && filter_input(INPUT_GET, 'count', FILTER_VALIDATE_INT)) {
$query->set('posts_per_rss', filter_input(INPUT_GET, 'count', FILTER_VALIDATE_INT));
}
return $query;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment