WordPress.org

Ready to get started?Download WordPress

Forums

How do I join this query with the wp_posts table? (1 post)

  1. ikjosh
    Member
    Posted 1 year ago #

    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>";
    								}
    							}

Topic Closed

This topic has been closed to new replies.

About this Topic