4

I have just updated to wordpress 3.6 and my theme seems to be ignoring my searchform.php file. Has this happened to anyone else?

5
  • 2
    You might look at the answer here. Commented Aug 2, 2013 at 16:48
  • Did you use the function in that post?
    – Drai
    Commented Aug 4, 2013 at 4:33
  • Yes, I edited the html within the function to match what my custom search form was!
    – RoseCoder
    Commented Aug 5, 2013 at 11:16
  • @RoseCoder: So you are saying you edited your functions.php with the functions code suggested on the forum thread, and also used the <?php get_search_form(); ?> code into the block where you want to show the search form. AND then it's still not working, right? ...And what about using a get_template_part() instead of that include() on the bottom as: <?php get_template_part('searchform',''); ?>? Commented Aug 6, 2013 at 22:45
  • 2
    I edited the code in functions.php and used get_search_form() and it worked fine! I deleted searchform.php as it was no longer needed.
    – RoseCoder
    Commented Aug 7, 2013 at 7:30

2 Answers 2

1

The answer is taken from WordPress.org Support Forum thread:
» 3.6 upgrade - searchform.php not working

As salcode said:
Adding this code to your functions.php should do the trick:

function search_form_no_filters() {
  // look for local searchform template
  $search_form_template = locate_template( 'searchform.php' );
  if ( '' !== $search_form_template ) {
    // searchform.php exists, remove all filters
    remove_all_filters('get_search_form');
  }
}
add_action('pre_get_search_form', 'search_form_no_filters');

And as from the experience from RoseCoder, you can remove the searchform.php as it was no longer needed.

0

In WordPress 3.6 searchform.php in your theme is still used by get_search_form(), unless is filtered out via get_search_form hook.

Sample code from get_search_form():

$search_form_template = locate_template( 'searchform.php' );
if ( '' != $search_form_template ) {
    ob_start();
    require( $search_form_template );
    $form = ob_get_clean();
} else {
    // compose the template, WordPress way
}

$result = apply_filters( 'get_search_form', $form );
if ( null === $result )
    $result = $form;

if ( $echo )
    echo $result;
else
    return $result;

Your problem was most likely generated by a faulty theme.

0

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