Search that splits results: content and products
On a site that combines a foundation's content with a store, the standard WordPress search mixes everything into one list โ someone searches for the "bylaws" and gets merch; someone searches for merch and gets an article. On top of that, content built with shortcodes can be "invisible" to search. We built a search that splits the results into two clear sections โ Store and Site pages โ and also indexes content from shortcodes, so nothing slips through.
How it works โ step by step
One field
The user types a phrase into one familiar search field.
Split into two sources
The system searches the store (products) and the site (pages and posts) separately.
Index of shortcode content
Content built with shortcodes is searchable thanks to a bespoke index โ previously it tended to be missed.
"Store" section
Products are presented separately โ you see at once what you can buy.
"Site pages" section
Pages and informational articles show up in a separate section.
A quick choice
The user knows at once where to click โ less frustration, more hits.
What you get
More accurate results
Products and content do not mix โ the searcher finds things faster.
More sales
Someone looking for merch sees the store section right away.
Content found too
Pages built with shortcodes are searchable โ the end of "invisible" subpages.
Better UX
A clear split into two sections means less confusion and higher satisfaction.
Lightweight and tailored
A bespoke solution fitted to this site, without heavy all-in-one plugins.
Details
The problem with standard search
By default WordPress dumps products, posts and pages into one list sorted "however it comes out". On a site that combines a foundation and a store, this disorients the user. On top of that, content generated by shortcodes does not always make it into the results โ the search simply does not see it.
How the split works
The search runs two independent queries: one over the store products, the other over the site pages and posts. We present the results in two separate sections ("Store" and "Site pages") with a combined hit counter, so the picture is clear at a glance.
Index of shortcode content
Pages built with shortcodes (e.g. FAQ, Help, Contact) have their content written to a special index, which makes them searchable just like ordinary posts. The user finds the answer even if it "lives" in a component rather than in classic text.
A bespoke results-page template (search.php) in the theme + an index of shortcode content in the plugin. Lightweight, on native WP_Query, without external search engines.
Two WP_Query in search.php
The results template runs separate queries: post_type=product and post_type=[page,post], each with its own limit and publish status. It renders two sections (Store / Site pages) and shows a combined counter (sum of found_posts). It handles the states: no phrase and zero results (with a link to /kontakt).
The _cs_searchable index
The centrumseo-shortcodes plugin writes the rendered shortcode content to the _cs_searchable meta, so pages built from components are caught by the standard "s" mechanism in WP_Query. This solves the typical problem of page-builder sites: the content is on the page, but the search does not "see" it.