Title: WP_Query and Custom Fields
Last modified: August 18, 2016

---

# WP_Query and Custom Fields

 *  [alernon](https://wordpress.org/support/users/alernon/)
 * (@alernon)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/wp_query-and-custom-fields/)
 * I’m trying to make a featured story at the top of my wp blog. I’m marking the
   stories I want to be featured with a customfield called “featured” with a value
   of true. In my header.php file I’m trying something like this:
 *     ```
       <?php $my_query = new WP_Query('meta_key=featured&meta_value=true&showposts=1');
         while ($my_query->have_posts()) :
          // Display post information
         endwhile; ?>
       ```
   
 * unfortunately, this is just displaying the latest post, regardless of the custom
   fields.
 * Also, later on within my main loop, I’d like to denote stories that were featured,
   but are now older. Is there and easy way to check a key/value pair from a post
   within the loop? Thanks.

The topic ‘WP_Query and Custom Fields’ is closed to new replies.

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [QP_Query](https://wordpress.org/support/topic-tag/qp_query/)

 * 0 replies
 * 1 participant
 * Last reply from: [alernon](https://wordpress.org/support/users/alernon/)
 * Last activity: [18 years, 9 months ago](https://wordpress.org/support/topic/wp_query-and-custom-fields/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
