WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a featured post type and a reviews post type. I would like to include reviews of a certain category (I use categories from the posts type) as well. How could query args be crafted?

A crude example:

get_posts(array('post_type' => array('featured-posts', array('review-posts', 'featured-category'))

Need to fetch all the posts in the featured-posts type, also all the posts in the review-posts type if the assigned category is feature-category.

UPDATE: Ended up not needing to implement this but I think Stephen S had the best guess.

share|improve this question
Can you explain it little bit more to understand your problem. It will help you and this community also. – Big Bro Yesh Apr 17 '14 at 6:08
Updated for a more specific description. I try to be as general as I can but still making sense. It's tough to find search results when questions are so specific to the scope of the asker's issue. – James Wagoner Apr 17 '14 at 19:05
up vote 0 down vote accepted

Untested, but I think you'd need to do two separate queries and merge them together:

$args = array(
 'post_type' => 'featured-posts'
$featured_posts = get_posts($args);

$args = array(
 'post_type' => 'review-posts',
 'category_name' => 'featured-category'
$review_posts = get_posts($args);

$result = array_merge($featured_posts->posts, $review_posts->posts);

$final_query = WP_Query($result);
share|improve this answer
Didn't end up needing to do this query but your's makes the most sense. – James Wagoner Apr 23 '14 at 5:43

Have you tried doing a query on both post types and including the category? I suspect that it will look only for posts in the featured category, then limit by the two post types, but nonetheless it's worth a try.

$args = array(
    'post_type' => array( 'featured-posts', 'review-posts' ),
    'category_name' => 'featured-category'
$res_posts = get_posts($args);

You can always try playing with taxonomy parameters (tax_query) as well.

share|improve this answer
I did try that at first and your assumption was correct. I opted to not use taxonomies with the post types as I wanted to use the main post type categories. – James Wagoner Apr 16 '14 at 23:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.