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