Skip to content
New site — Virtual Media Folders now has its own home. Visit vmf.soderlind.no →

Loupe Search Block

A search block for Loupe Search: live results as you type, a post type filter, category and tag facets, and sorting.

Loupe Search itself is engine-only. This add-on talks to it only through its public REST API (ADR 0002).

  • WordPress 6.9+
  • PHP 8.3+
  • Loupe Search 1.4.0+ (needs the GET /search-fields route)
  • Search as you type, with results, facets, sorting and pagination inside the block (Interactivity API).
  • Post type filter for every post type Loupe Search indexes.
  • Category and tag facets with result counts, for fields marked Filterable in Settings → Loupe Search.
  • Sort: Relevance, Newest first, Oldest first, Title A–Z, Title Z–A. Date sorts need post_date to be Sortable; title sorts need post_title to be Sortable. Options that are not allowed are hidden.
  • Highlighted snippets around the matched words.
  • Works without JavaScript: the block falls back to a plain search form that submits ?s= to the site’s search page.
  • Search insights: only the query a visitor settles on (or submits with Enter) is counted in Loupe Search’s Search insights, so search-as-you-type does not inflate the numbers.

Facets and sorts follow Loupe Search’s rules: when a search covers several post types, a field is only offered if it is allowed for all of them.

  1. Install and activate Loupe Search, and reindex.
  2. Install and activate Loupe Search Block.
  3. Add the Loupe Search block (loupe-search/search) to a page or template.
SettingDefaultNotes
Label“Search”
Placeholder“Search…”
Results per page101–100
Show post type filterOnHidden when only one post type is indexed
Show category and tag facetsOn
Show sort optionsOn
Default sortRelevanceFalls back to Relevance if the field is not Sortable
Show excerptOn
Highlight matchesOn

The block also supports wide/full alignment, margin, padding, and text and background colors.

Loupe Search Block screenshot
Terminal window
npm install
composer install
npm run build # or: npm start
npm test # Jest
composer test # PHPUnit
npm run lint:js

Author, date and custom-field filters (#71).

GPL-2.0-or-later. See LICENSE.