我想确定搜索中的最小字符数。在有许多条目的网站上,垃圾邮件发送者倾向于键入非常简短的“a”或“of”,服务器在尝试返回结果时崩溃。因此,我想确定要进行搜索的最小字符数, 例如,三个字符。
Relevanssi plugin 似乎是这样的。但我可以不使用任何插件。
提前谢谢。
我想确定搜索中的最小字符数。在有许多条目的网站上,垃圾邮件发送者倾向于键入非常简短的“a”或“of”,服务器在尝试返回结果时崩溃。因此,我想确定要进行搜索的最小字符数, 例如,三个字符。
Relevanssi plugin 似乎是这样的。但我可以不使用任何插件。
提前谢谢。
又快又脏,在搜索中把它放在get\\u header()之前。php
<?php
// Get the query string
$query = get_search_query();
// if the first & last char is space, rip them
$query = trim($query);
// if there are more than one space, rip to one space
$query = preg_replace(\'/\\s\\s+/\', \' \',$query);
// if chars count is less than 3, redirect them to homepage
if (strlen($query)<3){
wp_redirect( home_url() );
exit;
}
?>
我想知道是否有人知道我如何修改搜索以便它搜索分类法?目前,它只查找产品标题,而不查找分配给帖子的分类。请帮忙