【发布时间】:2012-02-24 18:18:32
【问题描述】:
我正在尝试用我自己的方式替换搜索表单。
一个示例插件:
<?php
/*
Author: whatever
Plugin Name: Some Name
Plugin URI:
Text Domain: some-domain
Version: 1.0
*/
function custom_search($form)
{
$form = "testing<form method = 'get' id = 'searchform' action = ' ".site_url()." ' >";
$form .= "<div><label class = 'hidden' for='s'>". __("Search for: ") . "</label>";
$form .= "<input type = 'text' value=' ". esc_attr(apply_filters('the_search_query', get_search_query())) ." ' name='s' id='s' />";
$form .= "<input type = 'submit' id='searchsubmit' value=' ".esc_attr(__('Look for it'))." ' />";
$form .= "</div>";
$form .= "</form>";
return $form;
}
add_filter('get_search_form', 'custom_search');
结果,不起作用。
我正在使用带有 211 主题的最新 Wordpress。
我在这里错过了什么?!?
编辑:如果主题有 searchform.php 文件,则该过滤器将被该文件覆盖。所以基本上过滤器只有在主题没有 searchform.php 时才有效。现在这只是愚蠢..
【问题讨论】:
标签: wordpress add-filter