Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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');
    if(function_exists('locate_template'))
        $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){
        if($v->isHidden()){
            $hidden.=$v->getInput(false);
            unset($inputs[$k]);
        }
    }
    include($formTemplate);
}

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?

share|improve this question
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
add comment

1 Answer

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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