你不需要两个目标搜索,而不是你可以使用这样的事情
一种形式做了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();
我不知道在哪里把这种形式的代码。我在我的网站上做的所有事情都包括侧边栏上的“搜索”小工具。我在哪里放代码? 同样的事情是,我必须通过ID变量newps,因为ID变量是在页面上使用。 –
对于两个自定义搜索,您有两种形式,上面给出了这些小部件的两种形式。 –