我不能百分之百确定您想要完成什么,但您可以通过将两个字符串串联起来“搜索两个字符串”:
function checkForAa($query){
if($query->is_search){
$search_string = $query->get( \'s\' );
if( stripos( $search_string , \'aa\' ) !== false){
$new_string = str_ireplace( \'aa\' , \'xxx\' , $search_string );
}elseif( stripos( $search_string , \'å\' ) !== false){
$new_string = (str_ireplace( \'å\', \'aa\' , $search_string ));
}
if( !empty( $new_string ) ){
// Concatenate the strings
$query->set( \'s\', $new_string.\' \'.$search_string);
}
}
}
add_filter(\'pre_get_posts\', \'checkForAa\');
$s = \'aabcd\';
$query1 = new WP_Query(
array(
\'posts_per_page\' => 3,
\'s\' => $s
)
);
var_dump($query1->request);
尽管字符串很长,但这种搜索效率很低,速度很快。