我知道了,谢谢
function my_search_pre_get_posts($query)
{
if($query->query_vars[\'s\'] != \'\' && is_search())
{
if(absint($query->query_vars[\'s\']))
{
$query->set(\'p\', $query->query_vars[\'s\']);
$query->set(\'post_type\', [\'property\']);
// Reset the search value
$query->set(\'s\', \'\');
}
}
}
// Filter the search page
add_filter(\'pre_get_posts\', \'my_search_pre_get_posts\');
对WordPress功能的非常好的学习。