php - Get record from current post -
i trying value of meta_value field current post.
<?php $cupost = $post->id; $registros = $wpdb->get_results( 'select meta_value auto_postmeta post_id = $cupost , meta_key="mg_game"'); echo $registros[0]->meta_value . "<br/>"; ?>
it not shows echo $registros
.
but if put directly on query number of post (post_id = 7
), shows value of meta_value
.
thy out:
<?php $cupost = $post->id;//first check if variable gets id, echo $cupost variable check. $registros = $wpdb->get_results( "select meta_value auto_postmeta post_id = ".$cupost." , meta_key= 'mg_game' "); echo $registros[0]->meta_value . "<br/>"; ?>
you have concatenate query string php variables
Comments
Post a Comment