我构建了一个自定义搜索页面,表单如下:
<form role="search" method="get" id="searchform" action="<?php echo home_url( \'/\' ); ?>">
问题是我希望搜索结果出现在搜索中。php而我被引导到索引。php
我怎样才能强迫自己总是去搜索。php?
我构建了一个自定义搜索页面,表单如下:
<form role="search" method="get" id="searchform" action="<?php echo home_url( \'/\' ); ?>">
问题是我希望搜索结果出现在搜索中。php而我被引导到索引。php
我怎样才能强迫自己总是去搜索。php?
If I get it correctly Wordpress loads the search template dynamically by the parameters delivered to it. Specifically the s
parameter. Meaning if you try to send the user to the http://www.example.com/search.php
you\'ll get 404 error page.
For now the only workaround I can think is to create a function which is hooked to the init
action hook that listens for a parameter in order to load the right file. The function must reside in the functions.php
of your theme (assuming you are developing a theme). The function goes like this:
function load_custom_search_template(){
if(isset($_REQUEST[\'custom_search\'])){
require(\'my_search.php\');
die();
}
}
add_action(\'init\',\'load_custom_search_template\');
get_search_form( $echo )
用于搜索表单。此模板标记首先搜索searchform.php
主主题文件夹中的文件。如果没有这样的模板,那么您将得到一个默认的搜索表单。根据您的输入参数,您可以回显或返回它以供以后使用。它的末端还有一个过滤器,其中包含完整的搜索表单HTML作为字符串:get_search_form
有一个参数:$form_html
.
使用get_search_form
-筛选以预/附加某些内容或完全替换表单使用自定义模板构建唯一的搜索表单,或者使用主题结构变得非常复杂,并使用筛选器从嵌套主题结构中的某个位置加载搜索表单:
// In your functions.php
function wpse65934_searchform_location( $form )
{
return get_template_part( \'subfolder/searchform\', \'default\' );
}
add_filter( \'get_search_form\', \'wpse65934_searchform_location\' );
尝试添加隐藏的关键字搜索输入,因为它将重定向到search.php 样板
<input type="hidden" name="s" id="search" value="<?php the_search_query(); ?>" />
我创建了一个新的棒球网站。为了创建网站,我基本上只是复制了我的足球网站并更改/修改了主题。由于我只是复制了一个网站,所有JetPack网站的统计数据都引用了旧的足球网站的统计数据。所以,顶柱、顶座、总视图、最繁忙等都是指足球交通。我如何删除这些旧的统计数据,2012年3月26日之前的所有数据?我应该注意到,旧网站使用了Wordpress。com站点统计插件,但我在复制到新站点后更新到Jetpack。我不知道这是否有什么不同,但我想我应该提一下。此外,仪表板小部件中会显示加密的\\u search\\u术语