I tried this code in phpmyadmin before and it works fine
SELECT meta_value
FROM wp_postmeta
INNER JOIN wp_posts ON post_id =564
WHERE meta_key = 'max_person';
But I don’t know how to insert it in function.php
I insert this code and it works
<? PHP
$postid = get_the_ID();
$maxperson = $wpdb->get_row( $wpdb->prepare(
"SELECT meta_value FROM wp_postmeta inner join wp_posts ON post_id= %d WHERE meta_key = 'max_person'", $postid
) );
?>
But when I var_dumped $maxperson
var_dump ($maxperson);
it returns
object(stdClass)#634 (1) { ["meta_value"]=> string(1) "5" }
the result should be “5” i dont understand what that means
You have to use custom query to get post by post ID or any other attributes.
go through WP documentation for detail.
http://codex.wordpress.org/Class_Reference/WP_Query
i got it
$value = (integer) $maxperson->meta_value;