Title: query_posts and meta_value=
Last modified: August 19, 2016

---

# query_posts and meta_value=

 *  [Dgold](https://wordpress.org/support/users/dgold/)
 * (@dgold)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/query_posts-and-meta_value/)
 * I’m trying to use query_posts in a multiple loops situation, and I could use 
   some help. I want to query all the posts that have any-value in the Custom Field
   with Key=”Map”. I want to display a list of the maps (a list of the custom field
   values, they are actually hyperlinks to maps) along with other info from the 
   posts like the post title.
 * Example,
 * >  Title Of My Post
   >  Here is my Map: MY CUSTOM FIELD VALUE HERE
 * So I’m reading:
    [http://codex.wordpress.org/Template_Tags/query_posts#Parameters](http://codex.wordpress.org/Template_Tags/query_posts#Parameters)
 * I learned that in WP 2.6+, you can use Custom field Parameters on query_posts
   like this:
 * >  Custom field Parameters
   >  Retrieve posts based on a custom field set in the
   > post **Both the meta_key and meta_value need to be set.** * meta_key= * meta_value
   > =
 * My question is, why does the Codex say that BOTH `meta_key` and `meta_value` 
   need to be set? I only want to set `meta_key=Map`. I don’t know what the `meta_value`
   will be. I want to get the meta_value from the posts that have `meta_key=Map`.
   What is the method to say `meta_value='anything'`?
 * By the way, I realize I can do this with a plugin (sort of), like Custom Field
   Values plugin. I’m trying to learn to do it with `query_posts` because it would
   give me more options and flexibility in the way I display it alongside other 
   post data.
 * I tried it with just meta_key and without using meta_value, and I think it actually
   worked, I’m just not sure why the Codex says that.
 * Thanks in advance for advice on this!

Viewing 1 replies (of 1 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/query_posts-and-meta_value/#post-928459)
 * Hey D,
 * See revised article for better explaination:
    [http://codex.wordpress.org/Template_Tags/query_posts#Custom_field_Parameters](http://codex.wordpress.org/Template_Tags/query_posts#Custom_field_Parameters)

Viewing 1 replies (of 1 total)

The topic ‘query_posts and meta_value=’ is closed to new replies.

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [meta_key](https://wordpress.org/support/topic-tag/meta_key/)
 * [meta_value)](https://wordpress.org/support/topic-tag/meta_value/)
 * [multiple loops](https://wordpress.org/support/topic-tag/multiple-loops/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [the-loop](https://wordpress.org/support/topic-tag/the-loop/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [17 years, 4 months ago](https://wordpress.org/support/topic/query_posts-and-meta_value/#post-928459)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
