WP:使用自定义查询对象技术

问题描述:

对于在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

OOP我只是犯了一个错误。 人们应该遍历对象数组等:

echo $myrows->post_title; 

或更详细

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