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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

1111. appearing after print sequence - php -

android - How to create dynamically Fragment pager adapter -