对于那些感兴趣的人,我通过以下方式绕过了它
add_rewrite_rule( \'members/search/(.+?)?$\',
\'index.php?page_id=\' . $member_page_id . \'&search=$matches[1]\',
\'top\'
);
因此,本质上是在搜索之后获取所有内容,然后进行处理,在解析查询时,我会像这样从“search”query\\u var解析查询
function wpse_set_pre_get_users( $query ){
if( ! is_admin() ){
$meta_query = $query->get( \'meta_query\' );
$meta_new_query = array();
if( get_query_var( \'search\' ) != \'\' ){
$search_arr = explode( \'/\', get_query_var( \'search\' ) );
foreach ( $search_arr as $search_val ) {
$vals = explode( \'=\', $search_val );
$serialize_value = serialize( strval( urldecode( $vals[ 0 ] ) ) );
$meta_new_query = array(
array(
\'key\' => $vals[ 1 ],
\'value\' => trim( urldecode( $vals[ 0 ] ) ),
\'compare\' => \'=\',
),
array(
\'key\' => $vals[ 1 ],
\'value\' => trim( urldecode( $vals[ 0 ] ) ),
\'compare\' => \'LIKE\',
),
array(
\'key\' => $vals[ 1 ],
\'value\' => trim( $serialize_value ),
\'compare\' => \'LIKE\',
),
\'relation\' => \'OR\',
);
$meta_query = array_merge( $meta_query, array( $meta_new_query ) );
}
$query->set( \'meta_query\', $meta_query );
}
}
}
add_action( \'pre_get_users\',\'wpse_set_pre_get_users\' );