• Resolved g01010

    (@g01010)


    Okay, I would like to present posts to users based on the choices they make in a form. Users can select some or all child categories from category ‘A’, for example, and some or all child categories from category ‘B’. So far so good.

    If, for example, a user selects categories 19 and categories 16 from parent category A, and categories 9 and 17 from parent category B, I would like to display posts that fall into categories (19 OR 16) AND (9 OR 17) – something like the following:

    if ( (in_category('19') || in_category('16')) && (in_category('9') || in_category('17')) ) {

    The problem I have is in how to generate an expression like this dynamically. The user’s choices are passed in to arrays but as the number of child categories a user might choose may vary, I am struggling to work out a way to code this.

    I’m fairly new to php and to WordPress so I’d appreciate a push in the right direction.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Dynamically including and excluding categories’ is closed to new replies.