Created
March 13, 2019 17:41
-
-
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
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 | |
/** | |
* 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