• I’m a bit confused as to how to use and/or statements in query_posts to grab a combination of different post types and taxonomy types.

    Let’s say that right now I have the following args set up for my query_posts:

    $args=array(
    ‘post_type’ => ‘posts’,
    ‘cat’ => ‘featured’,
    );

    I also want to add the following to my query..

    $args=array(
    ‘post_type’ => ‘review’,
    ‘review_cat’ => ‘top’,
    );

    How would I combine the two into my query, which would then include posts with the category of ‘featured’ as well as reviews with the review_cat (custom taxonomy) of ‘top’, while limiting the number of results to 3?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You may find better advise here…but please do not double post. (close the first one first)

    You can certainly use:

    $args=array(
    'post_type' => array('post', 'review'),
    'cat' => 'featured',
    );

    There’s isn’t a parameter called review_cat though – so I’m not sure what that’s for.
    https://codex.www.ads-software.com/Function_Reference/WP_Query

    Thread Starter Vcize

    (@vcize)

    Thanks esmi.

    ‘review_cat’ is my custom taxonomy.

    It appears that we’re close. That will allow me to get a post or review with a category of “featured”. However, what I’m looking to get is a post with a category of “featured”, or a review with a review_cat (custom taxonomy) of “top”.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘And/or statements in query_posts or wp_query’ is closed to new replies.