Alex Williams
Alex Williams

Reputation: 99

Get Field Values From WordPress Query

I used the following code to run a wordpress query... //using the $thePost[ID], get the fees associated with this accommodation from within the post_meta table.

$post_meta_querystr = "
SELECT *
FROM $wpdb->postsmeta
WHERE $wpdb->postsmeta.post_id = '$thePost[ID]'
";

$customPostMeta = $wpdb->get_results($post_meta_querystr);

The table has fields called "meta_key" and "meta_value". I'd like to know how I can use the value of any row in "meta_key" to get its corresponding value from the "meta_value" field? Any help is greatly appreciated.

Upvotes: 0

Views: 620

Answers (1)

Mauro
Mauro

Reputation: 1481

why don't you use the get_post_meta function?

Upvotes: 1

Related Questions