在Milo的帮助下,我找到了一个修改搜索查询的函数:
if( is_search() && empty($_GET[\'post_type\']) && !is_admin() ) {
global $wpdb;
$query = get_search_query();
$query = $wpdb->esc_like( $query );
$where .= " OR {$wpdb->posts}.ID IN (";
$where .= "SELECT {$wpdb->postmeta}.post_id ";
$where .= "FROM {$wpdb->posts}, {$wpdb->postmeta} ";
$where .= "WHERE {$wpdb->posts}.post_type = \'page\' ";<-page to post
$where .= "AND {$wpdb->posts}.post_status = \'publish\' ";
$where .= "AND {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id ";
$where .= "AND {$wpdb->postmeta}.meta_key IN(\'above-sidebar\', \'content-with-sidebar\', \'below-sidebar\') ";
$where .= "AND {$wpdb->postmeta}.meta_value LIKE \'%$query%\' )";
}
return $where;
我将post\\u type=\'page\'改为“post”,现在它工作得很好。
再次感谢你,米洛!
干杯