• I want to populate two dropdowns using post meta. One with all the unique city names and the other with the unique Area names based on what city name was selected.

    meta_value: City, Area

    For getting the list of Unique Cities, I’m using:

    $wpdb->get_col( $wpdb->prepare( "
          SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm
          LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
          WHERE pm.meta_key = '%s'
          AND p.post_status = '%s'
          AND p.post_type = '%s'
          ", $key, $status, $type ) );

    Could someone help me with the second custom query required, which will return the list of Areas based on the City Name passed.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom Query to select unique meta_value based on other 'meta_value's’ is closed to new replies.