Title: Custom conditional query problem
Last modified: August 19, 2016

---

# Custom conditional query problem

 *  [youngmicroserf](https://wordpress.org/support/users/youngmicroserf/)
 * (@youngmicroserf)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/custom-conditional-query-problem/)
 * Hi,
 * I have a question – I need to display two different post types on the same page,
   ordered by date, but the conditions that apply to the two post types are different–
   one needs to be selected based on category, the other based on custom field value.
 * While the query_posts variables allow to select two post types, I can only have
   one set of selection criteria, and I cannot combine them with a logical connector(
   like the SQL AND).
 * Or is there a way to do this and I haven’t found it?
 * Using info found in the support forum it’s no big deal to create a direct SQL
   query to achieve what I’m trying to do, but doing this and setting up the loop
   post info with setup_postdata() apparently means that it’s impossible to use 
   the built in paged navigation functions (previous/next). Is this correct? Is 
   there a way around this?
 * Do I need to write custom navigation functions for this? I would really prefer
   to use WP-functions. Is there any way to do this?
 * Thanks for your help!

The topic ‘Custom conditional query problem’ is closed to new replies.

## Tags

 * [custom-query](https://wordpress.org/support/topic-tag/custom-query/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [Post Types](https://wordpress.org/support/topic-tag/post-types/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [youngmicroserf](https://wordpress.org/support/users/youngmicroserf/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/custom-conditional-query-problem/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
