2012-02-04 75 views
0

對於在WordPress 3.3.1自定義查詢獲取記錄我使用WP:使用自定義查詢對象技術

$s = $_GET['s']; 
$myrows = $wpdb->get_results("SELECT post_title FROM $wpdb->posts WHERE post_content LIKE '%".$s."%' GROUP BY post_title"); 

,並返回對象數組

Array ([0] => stdClass Object ([post_title] => Charles Murray does it again) [1] => stdClass Object ([post_title] => The education crisis myth)) 

,但我怎麼能取POST_TITLE .. ?

+0

嘗試打印$ myrows [0] [0] – alfasin 2012-02-04 21:22:45

回答

0

OOP我只是犯了一個錯誤。 人們應該遍歷對象數組等:

echo $myrows->post_title; 

或更詳細

$post_id = '36'; 
$post = get_post($post_id); 
echo $title = $post->post_title;