Docs
Place the search / In your theme

Place the search in your theme

PXL Search works best where shoppers already search. In most themes it takes over the existing search with no extra work. When it can't, pick one of the methods below.

7 min readPlugin 0.47.13Settings › Appearance › Where it appears

Which method should I use?#

Your theme hasUse
A search box or search iconTake over your theme's search. It is on by default.
A menu, but no searchA menu link to #pxl-search
A block theme (site editor)The PXL Search block in the header
Widget areasThe PXL Search widget
A page builderdata-pxl-search or [pxl_search]
Its own search field you want to keepThe navbar field
No search anywhere on the pageA theme with no visible search bar

Take over your theme's search#

With Take over my theme's search on, shoppers type in your theme's search box as usual and pressing Enter opens PXL Search with what they typed. Your theme's search icon opens it too. Your theme keeps its own look.

It recognises a search by what it does, not by theme name: a search form, a search box, or an icon that opens a search panel. It gets there before the theme's own live-search dropdown starts.

Turn on Also swap the theme's search box for the PXL Search bar to replace the form itself with the PXL Search bar, which types example searches by itself. Leave it off if your theme draws its search inside its own panel or menu.

Missed?

If your theme's search button doesn't open PXL Search, list it under Also open it from, as CSS selectors: .my-search-button, #header-search.

PXL Search › Settings › AppearancePlugin 0.47.13
The PXL Search Settings page on the Appearance tab
  1. 1In the WordPress sidebar, open PXL Search and click Settings.
  2. 2Click the Appearance tab.
3 · Turn on the takeover
The Take over my theme's search row, switch on

The switch at the end of the Take over my theme's search row should be blue (on). It is on for new installs.

4 · Only if your search icon still opens the old search
The Also open it from field

Type your theme's selector in Also open it from, for example .header-search-toggle, then click Save changes at the bottom of the page.

Any element: data-pxl-search#

Add the attribute data-pxl-search to any element, in any theme or page builder. Its value is ignored.

HTML
<button data-pxl-search>Search</button>
<img src="search.svg" alt="Search" data-pxl-search>
  • On a button, image, menu item or div, a click opens the search. Elements that aren't buttons get keyboard access and open with Enter or Space.
  • On a search field, shoppers type in it and Enter opens the answers for what they typed.

Every theme has menus. Go to Appearance›Menus (or your theme's header menu), add a Custom Link with the URL #pxl-search, and name it Search. The link keeps your menu's own look. A full address ending in #pxl-search works too, and so does a button in a page builder.

WordPress › Appearance › MenusWordPress admin
The WordPress Menus screen with the Custom Links box
  1. 1Open Custom Links and type #pxl-search in URL.
  2. 2Type Search in Link Text, then click Add to Menu and Save Menu.

The [pxl_search] shortcode#

Shortcode
[pxl_search]
[pxl_search style="icon-text" label="Find a gift"]
[pxl_search style="bar" placeholder="Search or ask anything"]
OptionValues
stylebar, icon or icon-text. Default: your Appearance setting.
labelText next to the icon, up to 24 characters. Screen readers read it for every style.
placeholderText in the bar between typed examples, up to 60 characters.
WordPress › Pages › Add PageWordPress admin
A Shortcode block in the block editor holding the pxl_search shortcode
  1. 1Add a Shortcode block and type the shortcode in it.

The PXL Search block and widget#

In the block editor or the site editor's header, add the PXL Search block. It has the same options as the shortcode. In a classic theme, add the PXL Search widget to any widget area under Appearance›Widgets; it has style and text options.

WordPress › Pages › Add PageWordPress admin
The block editor with the Block Inserter open and the PXL Search block found
  1. 1Click the + (Block Inserter).
  2. 2Search for PXL Search and click the block. It has the same options as the shortcode.
WordPress › Appearance › WidgetsWordPress admin
The WordPress Widgets screen with the PXL Search widget in the list
  1. 1Find PXL Search in the list. Drag it into a widget area, or click it and pick the area.

The navbar field#

To keep a search field in your own header markup, mark the field. Shoppers type in it and press Enter to open the answers. Until they do, example searches type themselves into its placeholder.

header.php
<form role="search" class="site-search">
  <input type="search" data-pxl-search placeholder="Search or ask anything" aria-label="Search">
  <kbd>⌘K</kbd>
</form>

⌘ K (Ctrl K on Windows) opens the search on any page where it is placed. If your theme already uses that key for its own search box, PXL Search leaves it alone: the key focuses that box, and Enter opens PXL Search. The <kbd> is only a hint for your shoppers and is optional. The full guide to the navbar field.

More ways to fit it in#

Was this page helpful?