Domanda

Senario: I have created a custom post for doctors who are divided according to the Continent, Country and State which are provided in their metadata. i.e., doctors are posts.

I am creating an page for searching of the Doctors according to their Continent, Country and State which changes accordingly (Continent ==> Country ==> State).

Requirements: 1). If I select continent then doctors belonging to that continent gets listed also country and state dropdown gets populated accordingly. 2). If I select country(populated from above) then doctors belonging to that country gets listed also state dropdown gets populated accordingly. 3). If I select state(populated from above) then doctors belonging to that state gets listed.

Optional: I want to use ajax on dropdown change event listing gets updated.

Please Help!!!

Any suggestion is also appreciated.

Thanks in advance.

È stato utile?

Soluzione

The questions like homework are actually gets less answers than real questions...

if you have custom posts and you need filter them, you can use query_posts function of wordpress or get_posts... get_posts have args which helps you to query..

<?php 
$args = array(
    'posts_per_page'   => 5,
    'offset'           => 0,
    'category'         => '',
    'orderby'          => 'post_date',
    'order'            => 'DESC',
    'include'          => '',
    'exclude'          => '',
    'meta_key'         => 'doctors_country',
    'meta_value'       => 'England',
    'post_type'        => 'doctors',
    'post_status'      => 'publish',
    'suppress_filters' => true );


 $posts_array = get_posts( $args); 
?>

i hope this helps... you can do whatever you want with the array you have... IE: Triggering ajax request etc..

Solve one step and ask another question for next step..

Altri suggerimenti

I used this for some internal operations. Hope this helps the reader of this questions.

global $wpdb;
$results = $wpdb->get_results("select * from $wpdb->postmeta where meta_key = 'State'");
foreach ($results as $doc_meta_data) {
    echo "<br/>" . $doc_meta_data->meta_id;
    echo get_post_meta($doc_meta_data->post_id, 'address', true);
}
print_r($results);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top