Skip to content

Instantly share code, notes, and snippets.

@farinspace
Created March 13, 2019 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farinspace/2198b34dd342d31ee4dbf8b5af6090e1 to your computer and use it in GitHub Desktop.
Save farinspace/2198b34dd342d31ee4dbf8b5af6090e1 to your computer and use it in GitHub Desktop.
Alter "posts_per_rss" option with querystring param to limit the number of posts returned for an RSS Feed
<?php
/**
* Alter "posts_per_rss" option with querystring param to limit the number of posts returned for an RSS Feed.
*/
add_filter( 'option_posts_per_rss', 'my_posts_per_rss' );
function my_posts_per_rss( $option ) {
if( isset( $_GET['limit'] ) ) {
return (int) $_GET['limit'] ?: $option;
}
return $option;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment