2013-11-01 48 views
0

我修改了Searchform.php到:WordPress修改。 2只搜索小工具,搜索不同的内容

'search_id' => 'id', 'form_action' => ('http://local.amleo.com/newps/pulldata.php' 

对于第一个搜索插件,去到显示结果为别的定制PHP页面。

下一个搜索窗口小部件,我想搜索的类别“反垄断法热门话题”。不知道我该怎么做。有任何想法吗??

所以你可以想像:http://i.imgur.com/HSd9EEZ.png

的第一个搜索是一个我修改了Searchform.php的。第二个是我不确定的那个。

我以任何方式没有超级骗子PHP向导,但我可以遵循的方向相当体面。

回答

0

你不需要两个目标搜索,而不是你可以使用这样的事情

一种形式做了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(); 
+0

我不知道在哪里把这种形式的代码。我在我的网站上做的所有事情都包括侧边栏上的“搜索”小工具。我在哪里放代码? 同样的事情是,我必须通过ID变量newps,因为ID变量是在页面上使用。 –

+0

对于两个自定义搜索,您有两种形式,上面给出了这些小部件的两种形式。 –