Title: Retrieve posts by custom query
Last modified: August 19, 2016

---

# Retrieve posts by custom query

 *  [levani01](https://wordpress.org/support/users/levani01/)
 * (@levani01)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/retrieve-posts-by-custom-query/)
 * I added new column in wp_posts table in my WP database. The values in this column
   is either 0 or 1… Now how can I retrieve posts where the value is 1? Is it possible?
 * Thanks

Viewing 1 replies (of 1 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/retrieve-posts-by-custom-query/#post-1026247)
 * The [wpdb article](http://codex.wordpress.org/wpdb#SELECT_Generic_Results) has
   the answer.
 *     ```
       $myposts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE my_new_column = '1');
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Retrieve posts by custom query’ is closed to new replies.

 * 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, 1 month ago](https://wordpress.org/support/topic/retrieve-posts-by-custom-query/#post-1026247)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
