Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In my RSS feed, for example in a custom conditional URL:


I'm getting all my required tags, after editing wp-includes' file feed-rss2.php

With pagination enabled using &paged=# I can get into any pages within it. But when I get into a dead-end, it typically generates a 'not found' page.

Now my pagination is enabled showing 10 posts per page. So when cat=3 has 15 posts only, on first page it's showing 10, on second it's showing 5, and on third page it's showing a 'not-found' page.

So, now I'VE TO COUNT HOW MANY POSTS FOUND under this custom URL.
Please note, I'm not using any WP_Query() thing here and wp_count_posts not working for me.

  • How can I do this?

I've tried get_posts(), but it by default restricting the page to load only 5 posts max. So I passed a custom argument into it locally:

$allPosts = array(
    'numberposts' => -1
$posts = get_posts( $allPosts );
echo $count = count($posts);

NOT WORKING! It's exhausting the allocated memory size querying all, so it's I think not suitable because it's a time consuming thing, will pose load also.


share|improve this question
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.