How to get "key" from "value" in custom meta
-
i have a single post’s custom meta, ex:
custom meta key = moviename
custom meta value = HarryPotteri can use code:
<?php echo get_post_meta($post->ID, ‘moviename’, true); ?>
to get the post’s custom meta value “HarryPotter”but, how can i get the custom meta key “moviename”,
with the value “HarryPotter” that i know?now, i use
<?php
$customkeys = $wpdb->get_results(“SELECT meta_key FROM $wpdb->postmeta WHERE meta_value = ‘HarryPotter'”);
$meta_key = $customkeys[0]->meta_key;
?>just can get Key just first of one, it’s not current post Key.
because i have more post have value”harrypotter” in different Key.how can i get current post that key name
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to get "key" from "value" in custom meta’ is closed to new replies.