Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add WordPress’s built-in Search block to the archive template in a block theme, or place get_search_form() in the relevant archive template in a classic theme. The form accepts a search term; the archive or search-results template’s Query Loop or PHP Loop determines how matching posts are displayed.

Choose the method that matches your theme

Route Use it when What you edit
Block theme You can edit the relevant template in the Site Editor and want to place the form visually. Add a Search block to the blog archive template.
Classic theme You edit theme PHP files or need to position the form in template code. Call get_search_form() in the archive template.

Template names and available controls vary with the theme and site configuration. The WordPress Query Loop documentation describes the block’s post-display controls, while the Query Loop Block Editor Handbook provides additional implementation guidance.

Add search in a block theme

  1. Open the WordPress dashboard and go to Appearance → Editor to open the Site Editor.
  2. Open the template that renders the archive you want to change. Depending on your theme and configuration, this may be the blog home or a relevant archive template; names and controls are not universal.
  3. In the template, select the location for the search field and insert a Search block. A practical layout is an archive heading, the search form, the post list, pagination, and an empty-results message where appropriate.
  4. Keep the existing Query Loop that supplies the archive’s posts unless you have a specific reason to change it. The Query Loop can use the template’s default query or a custom query; its Post Template controls repeated content such as titles, excerpts, dates, and featured images. Optional Pagination and No Results blocks can provide navigation and an empty state.
  5. Save the template, then test the archive on the front end.

The Search block adds the control; it does not itself define the archive’s post layout. The Query Loop controls which posts appear and how they are presented.

Add search in a classic theme

  1. Identify the PHP template that renders the archive where the form should appear.
  2. At the desired location in that template, add <?php get_search_form(); ?>.
  3. Use a child theme or another safe theme-customization workflow when editing theme files, so a theme update does not overwrite your changes.
  4. Check whether the theme already has a searchform.php. WordPress first looks for that file in the child or parent theme; if it does not find one, it generates default form HTML.
  5. Load the archive on the front end and test a search.

The [WordPress function reference for get_search_form()](https://developer.wordpress.org/reference/functions/get_search_form/) documents the function’s aria_label argument for distinguishing multiple forms and the get_search_form filter for changing generated output. If you need custom markup, use searchform.php or the documented filter rather than scattering a hand-built form across templates. Retain WordPress’s expected search parameter and a usable label.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Understand what the form does—and what the archive does

A search form submits a term; the template that handles the request displays the matching posts. By default, WordPress’s form submits with GET to the site home URL and sends the search term in a field named s. WordPress uses that query variable to perform the search.

The archive’s Loop is separate: it repeats the content for posts in the page request’s default query. WordPress documents archive examples including category, tag, custom taxonomy, author, date, and search-result pages in its lesson on The Loop. In a block theme, the Query Loop provides corresponding controls for the posts and their repeated presentation. Adding a search box to an archive template does not mean you need to replace its archive query with a new custom list.

Test the archive and search results

  1. Open the actual archive on the front end and confirm the search control appears where intended.
  2. Search for a term known to match published content and confirm matching results display.
  3. Search for a term expected to have no match and check that the page gives visitors a clear empty state. The WordPress.org Documentation guide “Create a search page” uses the message “No posts were found.”
  4. Check that the archive’s post layout, pagination, and links still work. In a Query Loop, pagination is optional, and titles or featured images may need their link settings enabled.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.