WordPress – how to retrieve the ID from a given meta
With WordPress, it is common to use the get_post_meta($post, $meta_key) method in order to retrieve the value of a given meta. However for the ID, there is no ready-made method. The best solution I’ve found so far: $mid – $wpdb-get_var ($wpdb–prepare ("SELECT meta_id FROM $wpdb–postmeta WHERE post_id – %d AND meta_key – %s," $post, $meta-key);