I have this query to do in my code:
function get_item($id){
global $wpdb;
$post_id_query = "SELECT * FROM wp_postmeta WHERE post_id = ". $id ." AND meta_key LIKE '%main%'";
$call_post_id_call = $wpdb->get_results($wpdb->prepare($post_id_query));
return $call_post_id_call;
}
$main_item = get_item(34487);
If I run SELECT * FROM wp_postmeta WHERE post_id = 34487 AND meta_key LIKE '%main%'
on my DB it works...
I'm not very keen on wordpress to be honest.