• Resolved o2b

    (@o2b)


    How do I create a feed with the last 200 entries in a specific category?

    The only way I’ve figured out how to do this is with:

    <?php while( have_posts()) : the_post(); ?>
    <?php if (in_category('1')) continue; ?>

    … but this doesn’t work because I have 5000 entries in the system, and only 200 total entries in this category, and the above code times out when the feed is set to display anything above 3800 entries.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Options -> Reading

    Under the Syndication section, what happens if you change the “Show most recent” field to 200?

    Thread Starter o2b

    (@o2b)

    If I specify 200 posts in that field, my code above pulls the last 200 posts, then only displays the ones that are in the category I’ve specified, which is far fewer than 200.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Okay, first, remove any additional code you added. You can get a category feed without any code modifications whatsoever.

    Next, set the number of posts to 200. Not to 3800.

    Finally, get a catgeory feed. If you use pretty permalinks, this will be along the lines of:
    https://example.com/blog/category/your-category-name/feed/

    If you’re not using pretty permalinks, it’ll be something like this:
    https://example.com/blog/?cat=1&feed=rss2

    You don’t need to edit any code to get category feeds. They’re built in. You can add /feed/ to virtually any pretty permalink URL and get a feed for that thing and that thing alone.

    Thread Starter o2b

    (@o2b)

    I don’t know why I didn’t think the category feeds wouldn’t do what I want, but they do.

    I knew I would feel stupid, but now it works!

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘RSS Feed of 200 entries in a category?’ is closed to new replies.