Guide · Updated September 2026

How to Add WordPress Search to Any Converted Theme

Adding a WordPress search function to a theme, especially one converted from an existing webpage, is crucial for user experience and navigation. You can achieve this by integrating the standard WordPress search form into your theme's header or sidebar templates and then styling it to match your site's design.

Do it yourself in about a minute

Install Themify and get your first conversion free — no credit card.

Chrome browser logoAdd to Chrome — free

Understanding WordPress Search Functionality

WordPress provides a robust built-in search mechanism that allows users to query your site's content. At its core, the search functionality relies on a specific template file (searchform.php or integrated directly into other templates) that generates an HTML form. When a user submits this form, WordPress processes the request through its query loop and displays relevant posts and pages on a search results page (search.php).

For themes converted from external webpages, this built-in WordPress search often isn't automatically present or correctly integrated. Original static HTML designs typically lack the dynamic PHP and WordPress-specific functions required to interact with the database for search queries. Your primary goal will be to introduce these WordPress elements into your converted theme's structure.

The WordPress search form is typically invoked using `get_search_form()`, a template tag that looks for `searchform.php` in your theme's root directory. If `searchform.php` doesn't exist, WordPress falls back to a default, basic search form. Regardless, the output is an HTML form with an input field named `s` and a submit button, which WordPress then uses to perform the search.

Prerequisites: Before You Begin Adding Search

Before you dive into modifying your theme, ensure you have a few things in place. These steps will prevent common issues and streamline the integration process.

First, you need administrative access to your WordPress installation, including FTP/SFTP or file manager access to your theme's files. While you can often edit theme files directly within the WordPress admin (Appearance → Theme File Editor), it's generally safer to make changes locally and upload them, especially for more complex modifications. If you're working with a converted theme, you're likely already comfortable with file access.

A child theme is highly recommended for any modifications. While this article focuses on direct theme modifications for clarity, creating a child theme ensures that your changes aren't lost when the parent theme is updated. If your converted theme is a standalone entity and not designed to be updated, this concern is lessened, but good practice still dictates caution.

Finally, always back up your theme files before making any direct edits. A simple FTP download of your entire theme folder can save hours of recovery time if something goes wrong. This is a critical step, particularly when editing core theme files like `header.php` or `sidebar.php`.

Integrating the Search Form Into Your Theme Templates

The most common places to add a search form are the header, sidebar, or footer. Choose the location that best fits your design and user flow. For many designs, a header-based search (either a visible input or an icon that expands to reveal one) is intuitive.

To add the search form, you'll need to locate the relevant template file in your theme's directory. Common files include `header.php`, `sidebar.php`, or even a specific template part file like `template-parts/navigation.php` if your header is broken into modular components.

  1. Access your theme files via FTP/SFTP or your hosting control panel's file manager.
  2. Navigate to `wp-content/themes/your-converted-theme-name/`.
  3. Identify the file where you want to insert the search form. For instance, open `header.php`.
  4. Locate the HTML section where you want the search form to appear (e.g., within a navigation bar, alongside a logo, or in a utility area).
  5. Insert the WordPress template tag `<?php get_search_form(); ?>` into the desired location. For example, if you want it after your main navigation, find the `</nav>` tag and place it immediately after or within a wrapper `div`.
  6. Save the modified file and upload it back to your server, overwriting the original.
  7. Clear any caching plugins you might be using and refresh your website. You should now see a basic search form.

Creating a Custom `searchform.php` for Branding

While `get_search_form()` will display a default search form, it's often visually unappealing and doesn't match your converted theme's aesthetic. Creating a `searchform.php` file allows you to fully customize the HTML output and apply your theme's styling. This is where your converted theme's design prowess shines, allowing you to replicate the look of a static search bar if one existed on the original page.

This file should contain the HTML structure for your search form, including the input field named `s` and a submit button. It doesn't need the `<?php get_search_form(); ?>` tag itself, as it *is* the form that `get_search_form()` will call.

A basic `searchform.php` might look like this:

  • Create a new file named `searchform.php` in your theme's root directory (`wp-content/themes/your-converted-theme-name/`).
  • Add the following basic HTML structure. Remember to replace `your_theme_class` with a class that matches your theme's styling for input fields and buttons, or add new CSS rules later.
  • ```php <form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <label> <span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ); ?></span> <input type="search" class="search-field" placeholder="<?php echo esc_attr_x( 'Search &hellip;', 'placeholder' ); ?>" value="<?php echo get_search_query(); ?>" name="s" /> </label> <button type="submit" class="search-submit"><span class="screen-reader-text"><?php echo _x( 'Search', 'submit button' ); ?></span></button> </form> ```
  • Save this file. Now, whenever `get_search_form()` is called, it will use this custom structure instead of the default.

Styling the Search Form with CSS

After integrating the form, the next step is to style it to seamlessly blend with your converted theme's design. This involves using CSS rules in your theme's `style.css` file. Because Themify preserves existing CSS when converting a webpage, you'll likely have a good foundation to work from.

Identify the CSS classes used in your `searchform.php` (e.g., `.search-form`, `.search-field`, `.search-submit`). You'll then add or modify CSS rules in your `style.css` file to style these elements. This might involve adjusting widths, heights, colors, fonts, borders, padding, and margins to match your overall theme.

For example, if your original converted webpage had a sleek search bar in the header, inspect its CSS properties from the original `style.css` (or `main.css`, etc.) that Themify would have carried over. You can then apply those same properties to your WordPress search form's classes.

If your converted theme already has styles for generic input fields and buttons, you might simply need to adjust the `.search-field` and `.search-submit` classes to inherit or override specific properties. If not, you'll be writing new CSS. For instance:

  • Open your theme's `style.css` file (`wp-content/themes/your-converted-theme-name/style.css`).
  • Add CSS rules for your search form elements. Here's an example:
  • ```css .search-form { display: flex; align-items: center; gap: 10px; } .search-field { padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; width: 200px; /* Adjust as needed */ } .search-field::placeholder { color: #888; } .search-submit { background-color: #0073aa; /* Example primary color */ color: white; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; font-size: 16px; } .search-submit:hover { background-color: #005177; } .screen-reader-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; } ```
  • Save and upload `style.css`. Refresh your site to see the changes. Iterate on these styles until the search form visually integrates with your theme.

Creating a `search.php` for Search Results Display

After a user submits a search query, WordPress needs a template to display the results. This is handled by `search.php`. If `search.php` doesn't exist in your theme, WordPress will fall back to `index.php` to display the results, which often looks generic or broken because `index.php` is usually designed for blog posts or the homepage.

To provide a tailored search results page, you should create a `search.php` file. This file will contain the WordPress Loop to iterate through the search results and display them in a structured way. Since your theme was converted, you likely have existing templates for displaying blog posts or other content that you can adapt.

The easiest way to create `search.php` is to copy an existing template like `archive.php`, `category.php`, or even `index.php` (if it handles posts well) and then modify it. Your goal is to display each search result with its title, a snippet of content, and a link to the full post.

  1. Duplicate an existing content display template from your theme, such as `archive.php` or `index.php`. Name the new file `search.php`.
  2. Open `search.php`.
  3. Ensure the file includes calls to `get_header()` and `get_footer()` to maintain your theme's structure.
  4. Inside the main content area, you'll need the WordPress Loop. A basic loop structure for `search.php` looks like this:
  5. ```php <?php get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main"> <?php if ( have_posts() ) : ?> <header class="page-header"> <h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'your-text-domain' ), '<span>' . get_search_query() . '</span>' ); ?></h1> </header> <?php /* Start the Loop */ while ( have_posts() ) : the_post(); /** * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) * and that will be used instead. */ get_template_part( 'template-parts/content', get_post_format() ); endwhile; the_posts_navigation(); else : get_template_part( 'template-parts/content', 'none' ); endif; ?> </main><!-- #main --> </div><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?> ```
  6. Modify the `get_template_part('template-parts/content', get_post_format());` line if your theme uses a different path or structure for displaying post content. If your converted theme directly outputs post content within `index.php` without using `get_template_part()`, you can adapt that structure directly into `search.php`. For example, just include the `the_title()`, `the_permalink()`, `the_excerpt()` calls within the loop.
  7. Save `search.php` and upload it to your theme's root directory.

Verifying Your WordPress Search Implementation

After making all the necessary file modifications and CSS adjustments, it’s crucial to thoroughly test your search functionality to ensure it works as expected. Don't skip this step; a broken search can be highly frustrating for users.

Start by navigating to your website's front end. Locate the search form you just integrated. Input a term you know exists on your site, such as a blog post title, a common keyword from a page, or even a tag/category name. Press Enter or click the search button.

You should be redirected to a search results page (e.g., `yourdomain.com/?s=your-term`). Verify that the page displays relevant results. Check if titles are correct, excerpts are present, and links lead to the correct content. Also, test for pagination if you expect many results. If you search for a term that doesn't exist, ensure your `search.php` (or `content-none.php` if used) correctly displays a "No results found" message.

Visually inspect the search results page to ensure it matches your theme's design. Are the fonts, colors, and layout consistent? If not, return to your `style.css` and `search.php` files to make adjustments. Using your browser's developer tools (F12) can help you identify which CSS rules are being applied and what needs modification.

The Themify extension can streamline the initial conversion of any live webpage into a WordPress theme, preserving the original design, animations, and fonts. This provides a strong foundation, letting you focus on integrating dynamic WordPress features like search without rebuilding the entire design from scratch. With a high-fidelity converted theme, your styling tasks for `searchform.php` and `search.php` become primarily about adaptation rather than creation, leveraging the existing CSS structure Themify intelligently extracts.

Frequently asked questions

Why isn't my search form appearing after adding `<?php get_search_form(); ?>`?
Ensure you've placed the `get_search_form()` tag within a PHP block (`<?php ... ?>`) and that the file containing it is being loaded by WordPress (e.g., `header.php`, `sidebar.php`). Also, clear any caching plugins you might be using and check your browser's developer console for PHP errors.
My search form appears, but it looks unstyled. How do I fix this?
The default WordPress search form is very basic. You need to create a custom `searchform.php` file in your theme's root directory with your desired HTML structure, then apply custom CSS rules to the classes within that file (e.g., `.search-form`, `.search-field`) in your `style.css`.
My search results page looks broken or uses the wrong layout. What's wrong?
This usually indicates that your theme lacks a `search.php` file, causing WordPress to fall back to `index.php` or another generic template. Create a `search.php` file in your theme's root, including `get_header()`, `get_footer()`, and the WordPress Loop to display results correctly.
Can I add search functionality to specific custom post types only?
Yes, you can modify the WordPress query on your `search.php` or `functions.php` (using `pre_get_posts` hook) to restrict search results to specific post types. For example, add `set('post_type', array('post', 'your_custom_post_type'));` to your query arguments.

Try it in minutes — first conversion free

Themify is the fastest way to turn any live webpage into an installable WordPress theme (.zip). No coding, no rebuilding, no design handoff. Runs 100% locally in your browser.

No credit card required · 14-day money-back guarantee

Chrome browser logoAdd to Chrome — 1 free conversion