Loupe Cross-Site Search
Cross-site search for WordPress multisite, built as an add-on to Loupe Search. It maintains one combined Loupe index across the sites in your network and exposes a single search endpoint on a designated hub site, so a visitor can search every participating site at once and get one ranked list of results.
How it works
Section titled “How it works”- Combined index. Instead of querying each site’s index at search time, the add-on mirrors documents from every participating site into a single index (one Loupe database per post type) stored at a network-global path. Ranking and pagination are then a single, native operation. (ADR 0001)
- In-context mirroring, no
switch_to_blog. Each site mirrors its own posts into the combined index from within its own request context, reusing Loupe Search’s document builder so per-site options and filters apply. Backfill runs each site in its native context via a separate WP-CLI bootstrap. (ADR 0002) - Composite identity. Documents are keyed
{blog_id}_{post_id}and storeblog_id,blog_name, andurl, so results carry site attribution and link correctly across the network. - Public, published content only. Mirrors what Loupe Search itself exposes.
- Complete search block. A ready-to-use
Cross-Site Searchblock ships with the plugin: site and post-type facets, sorting, highlighted snippets, pagination, and result attribution — all configurable in the block inspector.
Design decisions are recorded in docs/adr/ and the domain glossary
in CONTEXT.md.
Requirements
Section titled “Requirements”- WordPress multisite 6.9+
- Loupe Search active on the network
- PHP 8.3+ with
pdo_sqlite,intl,mbstring(same as Loupe Search)
Installation
Section titled “Installation”-
Download
loupe-cross-site-search.zip -
Go to Network Admin → Plugins and upload
loupe-cross-site-search.zip, then activate the plugin network-wide. -
Go to Network Admin → Settings → Cross-Site Search and configure the hub site, participation, language, and post types.
-
Build the combined index:
Terminal window wp loupe-cross-site reindex
Once installed, the plugin updates itself from GitHub releases (via soderlind/wordpress-github-updater) — new releases appear on the WordPress Plugins update screen.
Configuration
Section titled “Configuration”Network Admin → Settings → Cross-Site Search
Section titled “Network Admin → Settings → Cross-Site Search”| Setting | Description |
|---|---|
| Hub site | The site that exposes the cross-site search REST endpoint. Defaults to the network’s main site. |
| Participation | All public sites, an allowlist, or a blocklist of sites. |
| Index language | Two-letter code used to tokenize the combined index (single language for the whole index). (ADR 0004) |
| Post types | Which post types are mirrored into the combined index. |
After changing participation, language, or post types, run
wp loupe-cross-site reindex.
Search block
Section titled “Search block”The plugin ships a ready-to-use Cross-Site Search block. Add it to any page or post on the hub site (or any same-origin site) and visitors can search the whole network from the front end — no code required.
Features
Section titled “Features”- Debounced search-as-you-type with a clear button and loading state.
- Facets for site and post type (checkboxes with live counts) that filter the results; a “Clear filters” control appears when any are active.
- Sorting: Relevance, Newest, Oldest, or Title.
- Highlighting of matched terms with cropped snippets (
<mark>), sanitized before rendering. - Per-result site badge, post-type label, and date.
- Pagination and a result count with query timing.
- Empty, loading, and error states with ARIA live regions.
Inspector settings
Section titled “Inspector settings”| Setting | Default | Description |
|---|---|---|
| Heading | — | Optional heading above the search box |
| Placeholder | Search… | Search input placeholder |
| Results per page | 10 | Between 1 and 50 |
| Site filter | on | Show the site facet |
| Post type filter | on | Show the post-type facet |
| Sorting | on | Show the sort control |
| Default sort | Relevance | Relevance / Newest / Oldest / Title |
| Show excerpt | on | Render highlighted snippets |
| Show date | on | Show each result’s date |
| Highlight matches | on | Request and render match highlighting |
On subdomain multisite the block makes a cross-origin request to the hub; place it on the hub site, use a subdirectory network, or add CORS headers. Prefer building your own UI? Query the REST API directly — see the developer guide.
Developer documentation
Section titled “Developer documentation”The REST API, search block, WP-CLI commands, extension filters, and test commands are documented in the developer guide. See also the architecture overview, decisions, and the domain glossary in CONTEXT.md.
License
Section titled “License”GPL-2.0-or-later. Copyright © Per Søderlind.
📦 Source: soderlind/loupe-cross-site-search · Edit on GitHub