WordPress.org

Forums

And/or statements in query_posts or wp_query (4 posts)

  1. Vcize
    Member
    Posted 3 years ago #

    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?

  2. Pioneer Web Design
    Member
    Posted 3 years ago #

    You may find better advise here...but please do not double post. (close the first one first)

  3. esmi
    Forum Moderator
    Posted 3 years ago #

    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.
    http://codex.wordpress.org/Function_Reference/WP_Query

  4. Vcize
    Member
    Posted 3 years ago #

    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".

Topic Closed

This topic has been closed to new replies.

About this Topic