Title: Using Custom Fields INSIDE Query Posts command
Last modified: August 19, 2016

---

# Using Custom Fields INSIDE Query Posts command

 *  [drexp2000](https://wordpress.org/support/users/drexp2000/)
 * (@drexp2000)
 * [16 years ago](https://wordpress.org/support/topic/using-custom-fields-inside-query-posts-command/)
 * I’ve been searching everywhere and asked a few WordPress masterminds, but everyone
   seemed to be stomped with this request. Hopefully you guys can help me with this.
 * I would like to use the data in a custom field to query certain posts in my custom
   page.
 * For example, in `query_posts(array('category__and' => array(2,6)));`
 * That queries posts that are BOTH in categories 2 and 6. Is there a way to replace
   the 2,6 with a custom field?
 * Like:
    `query_posts(array('category__and' => array(CUSTOMFIELD1DATA,CUSTOMFIELD2DATA)));`
 * Is that doable? I need something like this due to a complex list of categories
   I have and I really don’t want to make 15 different custom pages.
 * Please advise and thank you in advance.
 * -Andre

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Darrell Schauss](https://wordpress.org/support/users/darrellonsite/)
 * (@darrellonsite)
 * [16 years ago](https://wordpress.org/support/topic/using-custom-fields-inside-query-posts-command/#post-1506290)
 * The custom field parameters for query_posts are here..
    [http://codex.wordpress.org/Function_Reference/query_posts#Custom_Field_Parameters](http://codex.wordpress.org/Function_Reference/query_posts#Custom_Field_Parameters)
 *  Thread Starter [drexp2000](https://wordpress.org/support/users/drexp2000/)
 * (@drexp2000)
 * [16 years ago](https://wordpress.org/support/topic/using-custom-fields-inside-query-posts-command/#post-1506420)
 * Thanks for the reply, Darrell. I understand the custom field parameters and how
   they work. But what I’m trying to do is to do a custom query using the category
   ID # in the custom field value. So when I create a custom page, I can make each
   page have a dynamic query posting, thus not needing to create multiple custom
   query pages.
 * -Andre
 *  [adam533](https://wordpress.org/support/users/adam533/)
 * (@adam533)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/using-custom-fields-inside-query-posts-command/#post-1506624)
 * Not sure if you ever found a solution but I am looking for the exact same thing.
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/using-custom-fields-inside-query-posts-command/#post-1506625)
 * See the [answer](http://wordpress.org/support/topic/419879?replies=2#post-1585343)
   I posted to Adam533. Take a look at my BlueGrassMiataClub.com site. The pages
   under ‘Good Stuff’, ‘Event Talk’, ‘For Sale’, etc all use a single template.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Using Custom Fields INSIDE Query Posts command’ is closed to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)
 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [multiple](https://wordpress.org/support/topic-tag/multiple/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 4 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/using-custom-fields-inside-query-posts-command/#post-1506625)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
