I created a custom post type “podcast” and all podcasts are inside it. when I visit http://example.com/?feed=podcast
, it only shows latest 10 podcasts. How do I change it to 99?
I googled and found the code below:
function feedFilter($query) {
if (is_feed()) {
$query->set('posts_per_page','30');
}
return $query;}
add_filter('pre_get_posts', 'feedFilter');
It doesn’t work.
How to customize the feed items quantity in a custom post type?
The file where the
pre_get_posts
action runs iswp-includes/query.php
, If we look in that file, we’ll see that after the action is executed, theposts_per_page
setting is overridden for feeds with this bit of code:In this case, we can add a filter to the value of
posts_per_rss
to customize the feed quantity that way.You can use
post_limits
filter for feeds, or From backend you should be able to manage post count for feed:Just change it to number of posts in
Syndication feeds
you want to get.your code is almost correct.
I’ve modified somewhat.
Above should work