Want to make a WordPress custom search form? This guide shows you all the ways to create advanced search forms in WordPress.
Approximate read-time: 5 minutes
Hoping to create a custom WordPress search form for your website? Let's get that done! This guide shows you in WordPress how to add search forms. If you want to add a search box to your site, read on.
Here's what we'll cover:
- How to add the WordPress default search form to your site
- Creating a custom search form (with a WordPress form builder)
How to add the WordPress default search form to your site
By default in the WordPress core build, there is a search form ready to go. To insert it, you need to use the following code:
The above code will search for the searchform.php file in the WordPress theme you have active. If your theme doesn't have one, it will use the default WordPress form.
If you know how to code, you can try creating a search form manually. You just need to edit your searchform.php file. But if you want to save loads of time, one of the other solutions in this guide might be a better fit.
The default search form in WordPress has one more issue to be aware of. The search results displayed are from a global site search. That means the results show everything on your site! In many cases, you'll need a custom search form to drill deeper.
Does your WordPress theme include a search form?
It's possible that your WordPress theme includes a search form by default. Usually, you can find search form settings by looking into your theme options. These are located in the backend of your WordPress site.
If you can't find anything about search forms in your WordPress admin, it's still possible your theme has a shortcode that you can use to display your search form. Check out your theme's documentation or website to see if you can find out more.
And there's still one more possibility to rule out before we proceed. If you are using a page builder like Elementor or Beaver Builder, there might be a module you can use to insert a search form. Have a look!
Can I just use a search plugin?
Take a look at the WordPress.org plugin directory. Use their search engine and you'll quickly learn there are a ton of search plugins. While some of these can work well, just remember that having too many plugins on your WordPress site can slow things down.
Another issue with search plugins is that they don't always play well with all types of data. There's a lot that can go wrong when you are trying to get plugins, themes, and all your data to work together.
Having said that, if you are looking for a toolset that lets you search specific pages or custom post types, then a search plugin could be a working solution for you.
Creating a custom search form in WordPress
Still here? Want to learn how to add search forms in WordPress the easy way? Let's get to it!
To do this, we'll need some tech-savvy, but nothing like expert coding skills. Even if you are a pro developer, you can still save tons of time with this solution. If that sounds good, let's learn how to give WordPress an advanced search form.
What do you need to get started?
To build a custom search form that can give you a ton of control, you'll need a WordPress plugin. But it's not a dedicated search plugin. It's a form builder plugin!
Formidable Forms has a search form template that does the same thing as the default WordPress search feature (adds ?s= in the redirect URL). This can be adjusted to only search a single post type:
This can be adjusted even more too. Just swap in the WordPress parameters like 'post', 'p', 'date', 'year', 'month', and 'name'!
So of course, a form builder plugin has all the things you need to make search queries come to life. But it can get even more custom than that. For starters, you don't need to stick to a traditional search box. An advanced search can consider a few different data points, like the example below:
How do you create your custom search form?
We've created an entire tutorial here to get you started quickly. Working through that should help you see how you can create custom search forms for an unlimited set of scenarios.
In this article, we'll give a crash course though. This setup is dependent on the Formidable Views feature. If you want to create powerful stuff without all the work, Views will change your life! Here's what you need to create your custom search form:
- A data form (which has the stuff you want to be searchable)
- The results view (that displays the search results)
- A results page (that the user goes to after submitting their search)
Setting this is up isn't as hard as it might seem. For example, redirecting to another page using Formidable is easy:
Then we use some shortcodes to add more customizations. No extra HTML or CSS required here!
After that, we'll set up our custom fields to filter correctly. To get this WordPress search form filter going, just adjust the dropdowns and you're set.
And actually, if you want, you can display the search form and the search results all on the same page. See the example below:
Your search form can function in a variety of ways too. Want to accept partial form submissions? You can do that too! Take a look:
The last thing you might consider? Making sure your search form matches your site. With Formidable, you can tweak how your search field looks using our visual styler.
With a search form setup like the above, it's not hard to see how anything can be made searchable. Do you use WooCommerce? Wouldn't it be nice if all your products could be searched based on several different variables? You can do that too.
We hope you've found this information helpful. Please come back to the Formidable blog for more tips. We'll see you soon!
Read more about WordPress forms
Formidable Forms can be used to create ANY form you can imagine. Take advantage of our 14-day money-back guarantee and get Formidable Forms now!