Coding Agency for Web Development » WordPress Development » How to add Search to a WordPress website?

How to add Search to a WordPress website?

READING TIME: MIN

While your website’s clear organization, layout and quick navigation maybe your proud achievement, people will always look for the simplicity and ease of a search form – and they will expect consistently quick and accurate search results.

So this multi-part guide will look at how you can create the best possible WordPress search for visitors to your website. In Part 1, we discuss ways to add WordPress search to your website.

1. With your WordPress Theme

Some WordPress themes will let you easily add a search to your menu. For starters:

  • Select Appearance > Customize
  • Then, click on Header > Primary Menu
  • Select “Last Item in Menu”, then click “Search” in the options.

This adds a search icon and bar as an element at the end of your header navigation menu.

Some WordPress themes might not have the search setting in this same part of the theme customize options, but if present, it will be under the “Header” settings. Some other themes might not have the setting at all, in which case you can add the search bar using one of the following options.

2. Using a WordPress Widget

WordPress Widgets allow us to create special blocks in the elements around the main blog area, such as the sidebar and footer, to hold any content we need – content such as a search bar. For this:

  Why WordPress and Next.js Integration is the Future of Enterprise Websites

  • Navigate to Appearance > Widgets. Here you’ll find all the widgets possible. Some themes and templates may have just the barebones Sidebar and Footer options, or you may be presented with a more exhaustive array of choices.
  • Decide which block you want to place the search bar in.
  • Scroll to the end of your list of available widgets and select “Search”.
  • You can add it in one of two ways:
    • Click on the widget and select the block from a dropdown list.
    • Drag and drop the widget onto the section you choose.
  • Save changes and verify that the search bar appears on your website exactly the way you want it to.

3. Using a Page Builder Plugin

Elementor is one example of the sort of drag-and-drop Page Builder plugin wherein you can access the search widget.  While working on a new post or page for your website, then:

  • Keep the Elementor editor activated.
  • Search for the search widget in your Element list.
  • Drag the Search widget to the intended position on your page.

One good place for such a widget would be the 404 error page so users can get back to content.

With the plugin, you have more control over your search bar position than, say, Gutenberg would allow, and you can add it as a layer over or within the content.

  How to Perfectly Sell at the Checkout Page of Your WordPress Website?

4. Using a Theme with search built-in

This is by far the most convenient way to add search to your website, assuming you find the right kind of specialized theme or template. Such themes will automatically add a search bar.

Especially when search can get complicated, such as multiple filters and combinations, this functionality is best included with the theme itself.

5. Using Code to add Search

This way of adding a search requires that you feel at home with a basic coding scenario.

  • Select Appearance > Theme Editor.
  • You will now assign a new shortcode for a search element with the functions.php theme file.
  • At the end of the file contents, append the code:
add_shortcode ( 'shortcode_name', 'get_search_form');
  • To replace the “shortcode_name” with your name of choice for the search form. Ensure that the name you select is lowercase and devoid of spaces, numbers, and symbols.
  • Updating the file will allow you to use the shortcode within your website.
  • Add it like any other text content, but enclosed in brackets [] – e.g. [searchbar]
  • The search bar itself will not be visible while editing, but preview it and you can get a feel for how it’ll look on the website.

Search engines on the internet, and how they respond, have set a near-perfect benchmark for other search forms to emulate. Netizens often get their questions answered without ever having to leave the Google results page.

  How to Select a SEO Friendly WordPress Theme

The problem, though? The native search function in WordPress leaves a lot to be desired. It’s no Google, in short. In Part 2, we’ll look at ways to improve the WordPress search experience.

Tags:

Vipe Team

Author Vipe Team

Our tireless team who creates high-quality WordPress-related content for you 24/7/365.