WP Custom Fields Search is a great plugin but I've a problem regarding the plugin returning results using the homepage.

When I click the submit button, results are shown on the homepage instead of the search.php page!

Searching on the web, I've read that the plugin should output search results on the search page template or, if search.php is missing, on the homepage.

My theme has search.php but the plugin is not using it: I need to force the plugin to output search results in the search results page.

Looked at the plugin's code and quite sure that some code should be changed in the “extra_search_fields.php” file but I'm not sure where and how to force the results to output on the search template instead of the homepage. Guess that at about line 230 is where to hack the code:

function renderWidget($params=array(),$p2 = array()){
    $title = $this->getTitle($params);
    $inputs = $this->getInputs($params);
    $hidden = "<input type='hidden' name='search-class' value='".$this->getPostIdentifier()."'/><input type='hidden' name='widget_number' value='".$p2['number']."'/>";
    $formCssClass = 'custom_search widget custom_search_'.$this->nameAsId();
    $formAction = get_option('home');
        $formTemplate = locate_template(array('wp-custom-fields-search-form.php'));
    if(!$formTemplate) $formTemplate = dirname(__FILE__).'/templates/wp-custom-fields-search-form.php';

    foreach($inputs as $k=>$v){

function isPosted(){
    return $_GET['search-class'] == $this->getPostIdentifier();
function getPostIdentifier(){
    return get_class($this).'-'.$this->id;
function isHome($isHome){
    return $isHome && !$this->isPosted();
function rewriteHome($homeTemplate){
    if($this->isPosted()) return get_query_template('search');
    return $homeTemplate;

Can someone please help me?

  • 1
    Cannot verify your issue, but would like to extend my welcome to WPSE and congratulate for the very well formed and researched Question!
    – brasofilo
    Jun 25 '12 at 3:09

Instead of $formAction = get_option('home'); use $formAction = get_template_part( 'search' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.