WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to change the look of my searchform. It basically needs to have two text fields. I want this to be in form of a plugin, which anyone can activate. SO obviously I do not have any control over searchform.php. And I also read that if searchform.php is present, then echo parameter is ignored (http://codex.wordpress.org/Function_Reference/get_search_form#Notes)

This made me look at the code snippet under the heading "MOAR OBJECT BUFFERZ!!!" at:


I copied the code as it is and added a filter like: add_filter('get_search_form','shinra_searchform');

However, the code seems to go in an infinite loop. I put an echo statement after lines 11 and 12. The one after 12 never gets printed while the one after line 11 keeps on getting printed continously.

I tried changing the filter to pass the argument to:

  1. add_filter('get_search_form',shinra_searchform(true),1);

  2. add_filter('get_search_form',shinra_searchform(false),1);

  3. add_filter('get_search_form',shinra_searchform($echo),1);

But none of these work.

Can someone please help me out?

share|improve this question
up vote 0 down vote accepted

There is no safe way to catch the content of a searchform.php in this case. You could run output buffering on the complete page, but then you would probably run into conflicts with other plugins doing the same.

Alternative solution: Add a widget to your plugin that offers another search form. Ask your users to use that instead of the built-in widget or theme search form.

Some themes use a hard coded call to get_search_form() – there is nothing you can do.

share|improve this answer
Thanks a lot toscho. Yes, I have been searching over the porums for past 3 days, but to no avail. The only hope was a post hat mentioned the use of this hack of o/p buffering. But as you mentioned that might be inviting even more trouble. So I will consider other methods. Thanks a lot for your time and response. – user31670 Apr 18 '13 at 10:11
get_search_form() is a mess. The same hook is used as an action and as a filter, and there is no real API. – toscho Apr 18 '13 at 10:24

Your Answer


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.