Friday, 11 August 2023

How to Use Multiple Search Forms In WordPress

Do you want to make multiple search forms in WordPress?

By default, a search form will look through all your pages, posts, and media on your website. However, you can often improve the visitor experience by creating multiple forms that search specific categories, content types, and more.

In this article, we will show you how you can add and use multiple search forms on your WordPress site.

How to use multiple search forms in WordPress

Why Use Multiple Search Forms in WordPress?

A search form can help visitors find what they are looking for, fast. However, if you have lots of content, then it might make sense to create multiple forms that search specific types of content.

For example, if you run an online store, then you might create a smart WooCommerce product search that searches specifically for products.

You can also create an advanced search form for custom post types. For example, at WPBeginner, we have created custom post type search forms for our Deals and Glossary pages.

An example of a custom post search form

By using different search forms in different locations across your site, you can help visitors get accurate and helpful search results, no matter how much content you have published. This will improve the visitor experience and reduce the bounce rate.

That being said, let’s show you how to create multiple search forms in WordPress.

Create a New WordPress Search Algorithm With a WordPress Plugin

The easiest way to add multiple search forms to your WordPress website is by using the SearchWP plugin. It’s one of the best search plugins for WordPress, used by over 30,000 sites.

SearchWP

With SearchWP, you can search content that WordPress ignores by default, including custom post types, PDF files, WooCommerce products, and categories. You can also create multiple different search forms and then add those forms to any page, post, or widget-ready area.

Setting Up SearchWP

The first thing you need to do is install and activate the SearchWP plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, go to SearchWP » Settings and then click on the ‘General’ tab.

Activating the SearchWP search plugin

Here, you need to enter your license in the ‘License Key’ box. You can find this information in your account on the SearchWP site.

With that done, just click the ‘Verify Key’ button.

Create a Custom Search Algorithm For WordPress

After entering the license key, it’s a good idea to fine-tune how SearchWP indexes, searches, and displays your content. You can think of this as creating a custom Google search algorithm that’s just for your WordPress blog or website.

These are the general settings that all search forms will use by default. You can override these settings for the individual search forms.

To get started, head over to SearchWP » Algorithm.

Creating a search algorithm using SearchWP in WordPress

Here, you will see a section for the different content types that SearchWP searches by default, such as pages and posts.

You will notice that each item has an ‘Applicable Attribute Relevance’ scale. This is the weight (importance) that SearchWP will give to each attribute.

SearchWP's attribute relevance settings

Content that matches an attribute with high relevancy will appear higher in the search results. By contrast, content that matches an attribute that has less relevancy will appear lower on the search results page.

To change the relevancy, simply drag the different sliders. For example, if you move the ‘Title’ slider to the left and the ‘Content’ slider to the right, then the content will carry more weight than the title.

An example of attributes with different relevancy settings in a custom search algorithm

You can even tell SearchWP to search content that WordPress ignores by default.

To do this, click on the ‘Sources & Settings’ button.

How to make more content searchable in WordPress

You can now check the box next to the different content types. For example, you may want to make blog comments searchable or add PDF indexing and searching in WordPress.

When you are happy with your changes, simply click on the ‘Done’ button.

How to add comments, media, and more to the WordPress search results

This adds a new section for each content type. Once again, you can change the attribute relevance using the different sliders.

When you are happy with how the search algorithm is set up, just scroll to the top of the screen and click the ‘Save’ button.

Saving your improved WordPress search settings

SearchWP will now rebuild the index automatically. Depending on the speed of your Internet connection and your WordPress hosting provider, this may take a few minutes.

As soon as you see ‘Index Status 100%’, you will know that SearchWP has indexed all your content and settings.

Rebuilding the WordPress search index

Create Multiple Different Search Forms in WordPress

Now, you can create as many different search forms as you want.

To get started, head over to SearchWP » Search Forms and click the ‘Add New’ button.

How to create a new search form using SearchWP

This creates a new search form, ready for you to customize. For example, if you run a review website, then you might create a form that searches for product review posts and ignores other content like your blog posts and media.

To start, you will need to give the form a unique name by clicking on the small pencil icon next to ‘Search Form 1’.

Adding a name to the search form

You now type in a name for the custom search form.

Since you are going to make multiple search forms in WordPress, it’s important to use a name that helps you identify this form in the WordPress dashboard.

Adding a title to a custom search form

After that, you can choose a layout using the ‘Layout Theme’ thumbnails.

Some of these layouts are designed for specific search forms. For example, if you are creating a form that searches by category in WordPress, then we recommend selecting ‘Category Search’, as it already has many of the settings you need.

Choosing a layout for a custom search form

Simply click on the different themes to see a preview of how this form will look on your website. After making your decision, scroll to the ‘Custom Styling’ section.

The settings you see may vary depending on your theme layout. For example, if you selected ‘Quick Search’, then the ‘Quick Search’ setting will be enabled by default.

The quick search SearchWP theme and settings

You can disable and enable the different options using their toggles. The live preview will update automatically as you make changes, so you can try different settings to see what works the best.

Depending on your layout and the kind of form you want to create, you may need to enable and disable some of the ‘Custom Styling’ settings.

Do you want to create a form that searches by category? Then you will need to enable the ‘Category Search’ toggle.

After that, find the ‘Select Category’ field and type in each category that you want to include in the search results. For example, if you run an online store, then you may want to create forms that search specific WooCommerce product categories.

Creating multiple search forms for WordPress

If you want to allow visitors to filter their search results using factors like the author, post type, and tag, then you will need to click to enable the ‘Advanced Search’ toggle.

After that, scroll to the ‘Advanced Search Filter/s’ field. By default, SearchWP allows visitors to filter their results using Authors, Post Types, and Tags.

Creating an advanced search form in WordPress

To remove any of these filters, just click on its ‘X’ button. If you want to add more filters, then simply type their names into the field.

Then, when the right option appears in the dropdown, give it a click.

Adding filters to the WordPress search

By default, the form will search media, pages, and posts. If you have created custom post types, then you may want to include these in the search results.

To do this, find the ‘Type of search’ field and give it a click.

Adding multiple search forms to a WordPress website

You can now type in the name of each custom post type.

When the right custom post type appears, click to add it to the search.

How to search custom post types in WordPress

Do you want to exclude media, pages, or posts from the search results?

Then just click the small ‘X’ next to ‘Media’, ‘Pages’, or ‘Posts’.

Removing content types from your WordPress search results

When you are happy with the type of content that SearchWP will search, you may want to add some placeholder text to the search bar.

Here, we recommend letting visitors know how the search form works and the results they should expect to get. For example, if you have an online marketplace, then you may want to use text such as ‘Search for products’ or ‘Start shopping’.

By default, SearchWP will show a generic ‘Enter keyword and search’ message. You can replace this with your own messaging by typing into ‘Field Label’.

Adding a label to a search form on your WordPress blog or website

By default, the search form shows a magnifying glass and a blue ‘Search’ button.

To remove the ‘Search’ button, simply click to deactivate the ‘Search Button’ toggle.

Customizing a search form in WordPress

When you are happy with these settings, scroll to the ‘Form Style’ section.

Here, you can choose between different form styles, add a border, and change the font size.

Changing the SearchWP for style

Under ‘Button Style,’ you can customize the ‘Search’ button that appears in the form.

Finally, when you are happy with how the form is set up, you can scroll to the top of the screen and click on ‘Save’ to store your settings.

Saving your custom WordPress search form

To create more custom search forms with unique settings, simply repeat the exact same process described above.

Add Multiple Search Forms to Your WordPress Site

You can add multiple search forms to any page, post, or widget-ready area using either a shortcode or the Search Form block.

Since it’s the easiest, let’s start by looking at the block method.

How to Add Search Forms to a Page or Post

You may want to add a search form to a specific page or post or even show it inside the post content.

For example, you might add a search form to your FAQ page, documentation, help desk, knowledge base, or similar. This can improve the customer experience by helping users find answers and useful resources.

Search form in page example

To get started, simply head over to the page or post where you want to add the form.

You can then click on the ‘+’ icon and type in ‘Search Form’.

Adding a search form to a page or post using a block

When the right block appears, give it a click.

You can now open the ‘Select a Form’ dropdown and choose the form you want to show on this page or post.

Choosing a search form

When you are ready to make the search form live, just click on either ‘Update’ or ‘Publish’. Now, simply visit this page or post to see the search form in action.

How to Add Search Forms to a Widget-Ready Area

Another option is to add a search form to a widget-ready area, such as the sidebar or similar section. This is an easy way to show the same search bar across multiple pages on your WordPress website.

Go to Appearance » Widgets to see all the different areas where you can add widgets.

Adding a search widget to a blog or website

The options you see may vary depending on your WordPress theme. For example, if you are using the Astra theme, then the sidebar widget area is called ‘Main Sidebar’.

Simply click the ‘+’ block icon in the area where you want to add a widget.

Add new block widget

Then, type in ‘Search Form’.

When the right block appears, click to add it to your website.

Adding a search form widget to your website

You can now open the dropdown menu and choose the search form that you want to use.

When you are finished, just click the ‘Update’ button to make the search form live.

Adding a search form to a blog or website

Now, you can visit your site to see the improved search form.

For more on this topic, please see our guide on how to add and use widgets in WordPress.

How to Add Search Forms Using the Full Site Editor

If you are using a block WordPress theme, then you can add search forms using the full site editor. It includes areas that you can’t edit using the standard WordPress content editor. For example, you can add a search form to your 404 template in WordPress.

To get started, head over to Appearance » Editor in the WordPress dashboard.

Launching the full-site editor (FSE) in WordPress

By default, the full site editor shows your theme’s home template, but you can add a search form to any template.

In the left-hand menu, simply click on ‘Templates’ or Template Parts’ depending on where you want to add the search form.

Editing a block-based template or template part

You will now see a list of all the templates that make up your WordPress theme.

Simply find the template or template part that you want to edit, and give it a click.

Adding a custom search form to a website template or template part

WordPress will now show a preview of this template.

To go ahead and edit the template, click on the small pencil icon.

Adding a search form to an archive template

Now, click on the ‘+’ icon.

In the panel that appears, type in ‘Search Form’.

Adding the SearchWP search widget to WordPress

When the right block shows up, drag and drop it into your layout.

You can now open the dropdown menu and choose the search form that you want to use.

Showing different search form widgets in WordPress

With that done, just click on the ‘Save’ button to make your changes live.

How to Add a Search Form to WordPress Using a Shortcode

Another option is to add a search form using its shortcode. This may be an easier option if you want to add the same search form to multiple pages, posts, or widget-ready areas, as you can simply paste the same shortcode into multiple locations.

To get a search form’s shortcode, head over to SearchWP » Search Forms. Here, find the search form that you want to show and copy the value in the ‘Shortcode’ column.

How to add a search form to WordPress using shortcode

You can now add the shortcode to any page, post, or widget-ready area. For step-by-step instructions, please see our guide on how to add a shortcode in WordPress.

We hope this article helped you learn how to use multiple search forms in WordPress. You may also want to see our guide on how to increase your blog traffic and our expert picks for the best WordPress form plugins.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Use Multiple Search Forms In WordPress first appeared on WPBeginner.



from WPBeginner https://ift.tt/q0NXBZk
More links is https://mwktutor.com

No comments:

Post a Comment