Search Sidebar Widget not picking templates/searchform.php

I had this problem and I just want to let everyone know.

Wordpress will not replace your sidebar search widget with Sage’s searchform.php in templates directory. Correct me if I’m wrong, but I spent some time trying to debug this, which wasn’t happening in Roots.

If you want to use searchform.php all you need to do is create a file called searchform.php in Sage’s root directory and simply:

<?php get_template_part('templates/searchform'); ?>

Hope this helps someone else.


This is wrong…

I was a bit confused on this too. My custom searchform.php wasn’t getting picked up when it was in templates/. I moved it to the root directory and it’s now working.

I don’t see any reason to then pull in another file in templates/ as @justdayan did? Also, I don’t understand @ben’s response above. Could you explain?

I’m reviving this old thread because it was the clearest search result on the topic and the docs are a little confusing - searchform.php used to be in the templates folder. It now isn’t, but I can’t find any explanation of that modification in the changelog.

This may sound pedantic, but i created a pointer file in theme root called searchform.php and pointed it to templates/searchform.php to make everything clear. Stupid, i know, but you expect 1 thing 1 place, and something else happens… i’d rather be explicit.

cat searchform.php

<?php get_template_part('templates/searchform'); ?>