• At the moment my main page loop excludes a few categories and looks like this:

    <?php if ( is_home() )
    {
    query_posts($query_string . '&cat=-5,-15,-20');
    }
    ?>

    It outputs everything other than the posts in 3 categories(which I output elsewhere).

    I sometimes create posts in the excluded categories that I would like to highlight by including them in the main page as well. I assume this could be done by adding the posts to an additional category (say “Main Page” category id 30) and then changing the query or adding another if statement.

    I’ve fooled around and tried a few methods I thought might worked but haven’t succeeded.

    Thanks a bunch for help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • wpismypuppet

    (@wordpressismypuppet)

    Why don’t you just create a new category like “Main Page”, or “highlight”… then on your homepage, before or after your current query_posts, do a separate query_posts that just gets that “highlight” category. Put those in a special place on the site.

    Or do you need them integrated within your current loop? Mixed in with all the other posts on the homepage?

    wpismypuppet

    (@wordpressismypuppet)

    If you need them integrated, or mixed in with the other posts… create your “Main Page” and get it’s id… then add that id (say 30 as you mentioned) into your existing query like so:

    query_posts($query_string . '&cat=-5,-15,-20,30');
    Thread Starter NassMikk

    (@nassmikk)

    Thenks for the quick reply wpismypuppet.

    Yes I need them integrated with the other posts. I already have them in a separate location – but also want selected ones mixed with the main “feed” while still remaining in the separate location as well.

    I had tried

    query_posts($query_string . '&cat=30,-5,-15,-20');

    But that returned only category 30, and none of other categories (other non-excluded categories).

    I’ll give it a go with “30” at the end as in your suggestion.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘query_posts to exclude but also include category’ is closed to new replies.