您不需要两个搜索目标,而是可以使用类似这样的东西
一种形式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();