Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm looking for way to filter search results.

This is what I have so far

  • a custom post type of "doctors"
  • in each "doctor" post, there are numerous custom fields (male or female, location, specialty, ect)

I want the search form to filter these fields- for instance, display all the docs in a certain location that are female.

Here is the code than I am using that is currently working on one field only (I click for female doctors in tigard and I get all doctors in tigard).

<?php
$args = array(
    'post_type' => 'Doctors',
    'posts_per_page' => 1000,
    'orderby' => 'meta_value_num',
    'order' => 'ASC',
    'meta_query' => array(
          'relation' => 'AND',
          array(
             'key' => 'gender',
             'value' => 'yes',
         ),
    array(
        'key' => 'age-groups-served',
        'value' => 'yes',
    ),
    array(
        'key' => 'languages',
        'value' => 'yes',
    ),
    array(
       'key' => 'location',
       'value' => 'yes',
    ),
    array(
        'key' => 'specialities',
        'value' => 'yes',
    ),
    array(
        'key' => 'tests',
        'value' => 'yes',
    )
    )
);
$query = new WP_Query( $args );

if (have_posts()) : while (have_posts()) : the_post();

?>

FYI- I am using the "search everything" plugin so I can display the custom fields in search.

Here is the link if anyone is interested

http://western.art4orm-dev2.com/staff-directory/

Thanks for any help.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.