Title: Searching Custom Post Type   Custom Fields
Last modified: August 21, 2016

---

# Searching Custom Post Type Custom Fields

 *  Resolved [pshero](https://wordpress.org/support/users/pshero/)
 * (@pshero)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/searching-custom-post-type-custom-fields/)
 * Hey Gang, I’m hoping someone can give me a shove in the right direction here.
   I’m new to working with searchable custom post types (these are being used for
   a job board) and need to know how I’d write the search query for the following:
 * I have a custom post type called “opportunities” where each post is assigned 
   a category “profession” and sometimes a child-category “specialty”. Each custom
   post also has a custom field for “state”.
 * My search form is built out using Ajax so when a user selects a parent “profession”
   the sub-set of “specialty” auto-populates when there are sub-categories of that
   parent followed by a select-box full of states.
 * What I need to know is how I’d write the custom query to receive those variables
   from my form and only show results refined by child-cat (if it exists), otherwise
   parent-cat and state custom field.
 * Currently I’ve created a separate page template to return the search results 
   to and the following query args:
 *     ```
       <?php
               $args = array(
                   'post_type'=> 'opportunities',
                   's'    => $s);
                   query_posts($args);
       ?>
       ```
   
 * Any help is GREATLY appreciated! Thanks!

Viewing 1 replies (of 1 total)

 *  Thread Starter [pshero](https://wordpress.org/support/users/pshero/)
 * (@pshero)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/searching-custom-post-type-custom-fields/#post-3906531)
 * Sorry to BUMP… still looking for a hand with this… Thanks!

Viewing 1 replies (of 1 total)

The topic ‘Searching Custom Post Type Custom Fields’ is closed to new replies.

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [pshero](https://wordpress.org/support/users/pshero/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/searching-custom-post-type-custom-fields/#post-3906531)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
