是的,关于我的wordpress主题,我把它们放在一起……
当您单击搜索按钮(搜索字段为空)时,它会将您带到博客页面。我已经将index.php指定为博客页面,并创建了另一个页面,并将其指定为主页。
有人能帮上忙吗?这不是一个大问题,但它是一个小故障,我想摆脱。
谢谢。
泰瑞
发布于 2013-08-03 13:47:41
我也遇到了同样的问题,这是wordpress默认给出的。
但幸运的是,我发现了一些对我有帮助的东西。
在"Functions.php“中添加以下内容
function SearchFilter($query) {
// If 's' request variable is set but empty
if (isset($_GET['s']) && empty($_GET['s']) && $query->is_main_query()){
$query->is_search = true;
$query->is_home = false;
}
return $query;}
add_filter('pre_get_posts','SearchFilter');然后在search.php中替换下一行(第15行)
<?php if ( have_posts() && strlen( trim(get_search_query()) ) != 0 ) : ?>也许它也会对你有帮助
有关详细信息,请阅读:Customize empty search wordpress
https://stackoverflow.com/questions/15988564
复制相似问题