Forums

Custom Category RSS Feed question (3 posts)

  1. o2b
    Member
    Posted 5 years ago #

    I hope this hasn't been asked a hundred times. I searched, but couldn't find an answer to this specific problem. The answer is probably simple, and I will feel dumb.

    That having been said:

    I'm building a custom category feed. I need it to have at least 50 entries in it at all times (I'm pulling the data into a custom visualizer). I'm using the following code at the moment:

    ...

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

    ...

    I only have two categories, this excludes the one I don't want in the feed. unfortunately, this logic basically says this:

    Of the last [foo] number of posts (where [foo] is the "Show the most recent" setting) show all the entries that aren't category 1.

    The problem with this, of course, is that in the last [foo] entries there may not be 50 entries in the category I want.

    I need logic that says:

    Give me the last 50 entries from category 2.

    I feel stupid that I haven't found it, so any help will be appreciated.

  2. badassreviews
    Member
    Posted 4 years ago #

    Did you get this solved? I too am looking for info on how to keep certain things out of my feed.

  3. doug
    Member
    Posted 4 years ago #

    Don't jump right into the Loop. Try this:

    <?php
    query_posts("cat=-1")
    while( have_posts()) : the_post();
    ?>

    The first line limits posts to those that are not in category 1 (the minus sign excludes the category). After that, the Loop behaves normally. You don't need the 'continue' line, as no category 1 posts should show up.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags