I’m using this query to get values from wp_postmeta. I’d like to join it with the wp_posts table so I can get the post_title associated with the data. Then I’d like to output the post title as the <option> value How do I modify this? Thank you
$metakey = 'firm';
$counties = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'wpcf-country' ORDER BY meta_value ASC", $metakey) );
if ($counties) {
foreach ($counties as $county) {
echo "<option value=\"" . $county . "\">" . $county . "</option>";
}
}