Title: Get Posts by Custom Fields?
Last modified: August 18, 2016

---

# Get Posts by Custom Fields?

 *  [jayp](https://wordpress.org/support/users/jayp/)
 * (@jayp)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/get-posts-by-custom-fields/)
 * Is there a way to select posts based on a custom field?
 * For example, if I’m doing something like this:
 * $posts = get_posts(‘numberposts=1’);
 * can I do something _like_ this?
 * $posts = get_posts(‘numberposts=1**&customfield=x**‘);
 * I looked at the get_posts() function and the query_posts() function.
 * What I want to do is add a custom field to one post called “featured”, set it
   to 1 on the desired post, and then be able to highlight that post on the hompage.
 * I also want to be able to select the 9 most recent posts that do not have featured
   set to 1.
 * Am I asking the impossible?

The topic ‘Get Posts by Custom Fields?’ is closed to new replies.

## Tags

 * [metadata](https://wordpress.org/support/topic-tag/metadata/)
 * [query](https://wordpress.org/support/topic-tag/query/)

 * 0 replies
 * 1 participant
 * Last reply from: [jayp](https://wordpress.org/support/users/jayp/)
 * Last activity: [20 years, 5 months ago](https://wordpress.org/support/topic/get-posts-by-custom-fields/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
