Title: Query Custom Post Type with certain identifier
Last modified: August 21, 2016

---

# Query Custom Post Type with certain identifier

 *  [pshero](https://wordpress.org/support/users/pshero/)
 * (@pshero)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/query-custom-post-type-with-certain-identifier/)
 * I have a custom post type called “testimonials” and within that custom post type
   I have a checkbox called “show_on_page”. What I need to do is call two of those
   testimonials that have the “show on page” checkbox checked on my homepage.
 * My query looks like this… but I can’t figure out how to only grab posts that 
   have the “show_on_page” box checked.
 *     ```
       $args = array ( 'post_type' => 'testimonials', 'posts_per_page' => 2, 'orderby' => 'RAND' );
       	$custom_query = new WP_Query( $args );
       	if ( $custom_query->have_posts() ):
       	while ( $custom_query->have_posts() ) :
       	$custom_query->the_post();
       ```
   

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/query-custom-post-type-with-certain-identifier/#post-4616978)
 * The answer partly depends on how the checkbox is created and how the data is 
   stored in the database. Look in the postmeta table for meta_key = ‘show_on_page’
   and see what values are stored when the box is checked.
 * Then add the ‘meta_key’ and ‘meta_value’ parameters to your args. If the checked
   value is 1, you would add this:
 *     ```
       'meta_key' => 'show_on_page', 'meta_value' => 1
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Query Custom Post Type with certain identifier’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/query-custom-post-type-with-certain-identifier/#post-4616978)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
