你真的不需要使用&new WP_Query
只是new WP_Query
.
以下代码将解决您的问题。
add_filter( \'posts_search\', \'q166788_search_modify\', 10, 2 );
function q166788_search_modify( $sql, $query ){
// Only if our variable is true we do the black magic
if ( ! isset( $query->query_vars[\'search_conditional_toggle\'] ) || $query->query_vars[\'search_conditional_toggle\'] !== true ){
return $sql;
}
return preg_replace(\'/AND/\', \'OR\', $sql, 1 );
}
// The actual search
$s = \'bord\';
$args = array (
\'author\' => \'1,2,3,4,5\',
\'s\' => $s,
\'search_conditional_toggle\' => true, // Make the black magic happen
\'posts_per_page\' => -1
);
$allsearch = new WP_Query( $args );
var_dump( $allsearch );