Home » Documentation » Product Search » Adding Search to Your Store » Adding Search to Your Menu or Header

Adding Search to Your Menu or Header

To add the Elevated Product Search form to your menu or header, place the [elex_product_search] shortcode using your theme’s Site Editor, Customizer, header widget area, page builder, or header template file.

Table of Contents

Step 1: Add to Header via Site Editor (Block Themes)

Go to Appearance › Editor.

Select Template Parts from the left navigation, then choose Header.

Site Editor with Header template part selected

Click the area where you want the search form, such as next to the site logo or at the far right of the navigation row.

Click the + button to add a block. Select Shortcode.

Site Editor with shortcode block added

Enter the shortcode:

[elex_product_search]

Click Save.

Step 2: Add to Header via Customizer or Widgets (Classic Themes)

Theme Customizer

If you are using a classic theme and want to add WooCommerce search to your header, look for header widget areas or header builder options in the Customizer.

Go to Appearance › Customize.

Look for a Header section, Header Builder, or Header Widgets option in the left panel. The exact name depends on your theme.

Customizer left panel with Header section expanded

Click the header area where you want the search form. Add a Shortcode block or HTML widget and enter:

[elex_product_search]
Customizer header shortcode added to HTML block

Click Publish.

Header Widget Area

Go to Appearance › Widgets.

Look for a widget area named Header, Header Right, Top Bar, or similar.

Widgets screen showing Header Right widget area

Add a Shortcode block and enter:

[elex_product_search]
Widgets screen with Elevated Product Search shortcode added

Click Update.

Step 3: Add WooCommerce Search to Header via Page Builder

If your theme uses a page builder for the header template, add the shortcode using that builder’s Shortcode or HTML widget.

Open your header template in your page builder.

Locate the area where you want the search form.

Add a Shortcode widget (or HTML widget, depending on the builder).

Shortcode properties panel with the shortcode entered

Enter the shortcode:

[elex_product_search]

Save the header template.

Step 4: Add Product Search to Header via Code Snippet

Theme File Editor

For direct theme file editing, add the shortcode to your header template file.

Go to Appearance › Theme File Editor.

Select header.php from the right-side file list.

Theme File Editor with header.php selected

Locate where you want the search form to appear. Add:

<?php echo do_shortcode('[elex_product_search]'); ?>

Click Update File.

Note: Editing theme files directly carries risk. Create a child theme first, or use a code snippet plugin as described below.

Use WPCodeBox to Add Product Search to Header

WPCodeBox provides a safer way to add code to your site without editing theme files directly.

Install and activate WPCodeBox from the WordPress plugins page.

Go to WPCodeBox in your WordPress admin sidebar.

Click New Snippet in the left panel.

WPCodeBox add new snippet

Enter a title for your snippet (for example, “Header Search Form”).

In the code editor, enter:

echo do_shortcode('[elex_product_search]');

Under How to run the snippet, select Always (On page load) and set Where to insert the snippet to a hook that corresponds to your header area. Common options include wp_header or wp_head, or a theme-specific hook like astra_header if your theme provides one.

add header form code to WPCodeBox and insert the snippet to wp head

Click Save & then change the toggle to Enabled.

Visit your site to confirm the WooCommerce search form appears in the header.

Step 5: Verify Product Search Placement in Header

Visit your site frontend and check the following:

  • Desktop view: The search form appears next to or near the navigation menu
  • Mobile view: The form is visible or accessible through the mobile header layout
  • The search input is functional and displays live results when you type

If the search form appears in the wrong location, return to the Site Editor, Customizer, page builder, or code snippet and adjust its position until it sits where you want it.

Search bars in WooCommerce stores are placed in the header area. The header is the consistent top section of every page, making search accessible no matter where a customer is on your site.

If you previously removed a default theme search bar, add the [elex_product_search] shortcode in that same location. This preserves your header layout while upgrading the search functionality.

Troubleshooting

The shortcode displays as plain text in the header

Make sure the location where you added the WooCommerce product search supports shortcode execution. Some theme Customizer fields and widget areas do not process shortcodes by default. If this happens, switch to a Shortcode block (block themes), a Text widget with shortcode support enabled, or use the do_shortcode() PHP approach.

The search form breaks the header layout on mobile

Adjust the Max Form Width and Mobile breakpoint settings in Elevated › Product Search › Settings › Basic Settings. If your theme collapses the header into a hamburger menu on mobile, the search form may need to be placed inside the mobile menu panel rather than the desktop header area.

The form appears but the search returns no results

Confirm your search index is built. Go to Elevated › Product Search › Settings and check the Indexer section. If needed, click Force Index Rebuild.

Changes do not appear on the frontend

Clear your site cache (from any caching plugin) and browser cache. Some page builders also require clearing the builder cache before frontend changes display.

Add WooCommerce Product Search to Header – Related Documentation

On this page
Want More?

Get Every Elevated Extension You’ll Ever Need—One Payment, Yours for Life

Build faster, smarter, and without limits. A single purchase unlocks our entire library today and every new extension we release in the future. No renewals, no upsells, just lifetime power at your fingertips
+All other extensions for unlimited sites

The All Access Pass, available for a limited time

This exclusive package won't be around forever, as we will eventually move to a subscription model. This is your chance to get in early.
  • All Current Extensions
  • All Future Extensions
  • No Renewal Fees
  • 90-Day Money-Back Guarantee