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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -