• Hi, I have 5 main categories and one feature category (#6). For every main category I have feature posts. On my custom frontpage I’d like to show the most current feature for each of the 5 main categories.

    I’ve tried several hacks, asides, plugins, adhesives I stumbled across in the last few days, but all I want is a simple query_posts(‘cat=1,6’) as i found it in the codex http://codex.wordpress.org/Template_Tags/query_posts Unfortunately this functions does a query like 1 OR 6. Well, to keep a long story short. All I need is 1 AND 6. How can this be done?

    Any hints? Thanks for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Couldn’t you just do query_posts('cat=6')?

    Thread Starter theworkisdone

    (@theworkisdone)

    Hi Michael,

    hell, that would be really to simple 🙂 I’ll explain… query_posts(‘cat=6’) gives me the latest n number of feature posts – btw I know I can limit the number – regardless of the second category that post is associated to.

    So I could come up with one or more feature posts for category #1 and with none for e.g. #5 cause I do not write features for #5 that frequently.

    I really need for each of the big five categories excactly one feature on the frontpage.

    After re-reading the OP: wouldn’t this home page template help?
    http://wordpress.org/support/topic/38046?replies=31
    at least as a starting point…

    Yeah I know it is simple but couldn’t you just assign category 6 to only the 5 posts you want featured?

    Thread Starter theworkisdone

    (@theworkisdone)

    I have to admit: Finally I went with the cat=6&showposts5 option an checked in the loop with a few conditionals in_category(x). It’s not the best solution, cause now I might end up with the latest five features beeing of the same category if my co-authors are messing up, well…

    Maybe I’m going to file a feature request for something like cat=1+6. We have at least a solution for query_posts(‘cat=-6’) so the other way round shouldn’t be a big problem for the devs, no?

    Again thanks for your help.

    Okay, then how about using the query_posts(‘cat=6’) then use the logic here The_Loop#Exclude_Posts_From_Some_Category to “include” just Category 1 posts from the cat=6 subset. Of course you’d use something like:
    <?php if ( in_category('1') ) { ?>

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

The topic ‘query_posts does OR not AND when querying for multiple categories’ is closed to new replies.