我要在代码中执行以下查询:
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);
如果我跑步
SELECT * FROM wp_postmeta WHERE post_id = 34487 AND meta_key LIKE \'%main%\'
在我的DB上它工作。。。
老实说,我不太喜欢wordpress。