How To Search In WordPress

Searching for content in WordPress can be an essential feature for both website administrators and users alike. In this guide, we will explore different ways to search for content within your WordPress site, including using the default search functionality, enhancing search capabilities with plugins, and adding custom search filters.

1. Using Default WordPress Search

WordPress comes with a built-in search feature that allows users to easily search for content within your website. To add the search box to your site, you can simply use the following widget:

  • In the WordPress admin dashboard, navigate to Appearance > Widgets.
  • Locate the Search Widget and drag it to your desired sidebar or widget area.

Now your site should display a search box that users can utilize to find content on your website.

2. Enhancing Search with Plugins

While the default WordPress search functionality is useful, it may not always provide the most relevant results or have advanced search features. To improve your site’s search capabilities, you can use search enhancement plugins, such as Relevanssi.

Relevanssi is a popular WordPress search plugin that improves the relevancy of search results, supports searching for phrases with quotes, and allows searching for content in custom fields or taxonomies. To install and set up Relevanssi, follow these steps:

  • In your WordPress admin dashboard, go to Plugins > Add New.
  • Search for Relevanssi in the search bar, and click Install Now on the plugin card.
  • Once the plugin is installed, click Activate to enable the plugin.
  • Navigate to Settings > Relevanssi, and configure the plugin settings to meet your search requirements.
  • Finally, click Save the options and build the index to create the search index for your site.

3. Adding Custom Search Filters

If you want to add custom search filters to your WordPress site, you can create a custom search form using the WP_Query class. This allows you to create search forms with specific filters to tailor search results to your users’ needs. For example, if you have a blog with different categories, you might want to create a search form that allows users to search for posts within specific categories.

To create a custom search form with category filters, follow these steps:

  • Create a new PHP file (e.g., custom-search.php) in your theme directory.
  • Add the following code to the custom-search.php file:

  • ‘post’,
    ‘category_name’ => $_GET[‘category’],
    ‘s’ => $_GET[‘s’]

    // Instantiate custom query
    $custom_query = new WP_Query($custom_query_args);

    // Output custom query results
    if ($custom_query->have_posts()) {
    while ($custom_query->have_posts()) {
    echo ‘

    ‘ . get_the_title() . ‘

    echo ‘

    ‘ . get_the_excerpt() . ‘

    } else {
    echo ‘No results found.’;

    // Reset post data

  • Next, create a search form in your desired template file (e.g., searchform.php):

  • Finally, include the search form in your desired template file using the following code:
  • With this custom search form, users can now search for content within specific categories on your WordPress site.


    Searching for content in WordPress can be easily achieved using the default search functionality, enhanced with plugins, or customized with custom search filters. By providing users with efficient search options, you can ensure that they quickly find the content they are looking for, ultimately improving their experience on your website. Happy searching!