我将搜索表单.php修改为:
'search_id' => 'id', 'form_action' => ( 'http://local.amleo.com/newps/pulldata.php'
对于第一个搜索小部件,转到显示其他内容结果的自定义 PHP 页面。
下一个搜索小部件,我想搜索类别"AML热门话题"。不知道我该怎么做。任何想法??
因此,您可以可视化: https://i.stack.imgur.com/UFGBQ.png
第一个搜索是我修改搜索表单.php的搜索。第二个是我不确定的。
无论如何,我都不是超级骗子PHP向导,但我可以非常体面地遵循指示。
你不需要两个目标进行搜索,而是可以使用这样的东西来完成
一种newps
表格
<form method="get" id="searchform" action="<?php echo esc_url( home_url() ); ?>">
<input type="text" value="<?php echo esc_attr( get_search_query() ); ?>" name="s" id="s" />
<input type="hidden" value="newps" name="key" />
<input type="submit" id="searchsubmit" value="<?php esc_attr_e('Search','Aggregate'); ?>" />
</form>
另一个AML
<form method="get" id="searchform" action="<?php echo esc_url( home_url() ); ?>">
<input type="text" value="<?php echo esc_attr( get_search_query() ); ?>" name="s" id="s" />
<input type="hidden" value="aml" name="key" />
<input type="submit" id="searchsubmit" value="<?php esc_attr_e('Search','Aggregate'); ?>" />
</form>
在主题的根文件夹中创建一个search.php
文件,如下所示
get_header();
// if you get `key` then it will be your custom search
// otherwise, default search will be performed
if(!empty($_GET['key'])) {
$key = $_GET['key']; // it will be either 'newps' or 'aml'
$search = $_GET['s'];
// modify the query using your $key and $search param
query_posts(...);
}
if (have_posts()) :
while(have_posts()): the_post();
// the_title() and more...
endwhile;
endif;
// reset the query if modified
if(!empty($key)) wp_reset_query();
get_sidebar();
get_footer();