Open the Search Results template in the Site Editor
Open Appearance, then Editor, click Templates and select Search Results. The results list on that template is the Query Loop block, and the Replace control on the block toolbar swaps its pattern. Save, then run a search on the front end to see the change.
- In the WordPress admin, open Appearance, then Editor. Older block themes show this as Site Editor.
- Click Templates, then scroll to Search Results and open it.
- Open List view to see the structure. The Search Results title block sits above the Query Loop block.
- Select the Query Loop block, then click Replace in the block toolbar and pick a different pattern.
- Add a Post Excerpt block under the title, and set the featured image aspect ratio to 3:4 so every thumbnail matches.
- Click Save, then search for a term on the live site. The page is fixed when the results use the new layout.
On a classic theme there is no Search Results template in the editor. Copy search.php from the parent theme into a child theme and edit the copy, because a theme update overwrites the parent file.
Change which posts the search returns
The default query returns posts and pages. A filter on pre_get_posts narrows the post types, skips the admin, and caps the number of results per page.
add_action( 'pre_get_posts', 'webji_search_types' );
function webji_search_types( $query ) {
if ( $query->is_search() && ! is_admin() && $query->is_main_query() ) {
$query->set( 'post_type', array( 'post', 'page', 'product' ) );
$query->set( 'posts_per_page', 12 );
}
}
Put it in the child theme's functions.php, or in a snippets plugin if you do not want to touch files. The three checks matter: without is_main_query() the filter also rewrites menus and widgets that run their own queries.
Drop product from the array on a site with no shop. Add a custom post type only when its template can render the result.
Make results more relevant without touching code
Core search matches the post title, the content and the excerpt, and lists matches by date rather than by relevance. A term buried in an image caption or a custom field will not be found at all.
A search plugin such as Relevanssi or SearchWP indexes those fields, allows partial-word matches, and lets you weight the title above the body. Install one, run its index build, then re-run the same test searches. Prices and licence terms sit with each vendor.
Site search has no AND or OR operators in core WordPress. If a client needs exact-phrase behaviour, that is a plugin feature, not a template edit.
Style the results and keep the theme intact
Block themes take their styling from the Site Editor: select a block, open Styles, and change spacing, borders and typography there. Classic themes need CSS in the child theme's stylesheet, or the change disappears at the next theme update.
Keep the result title, the excerpt and one image. A search page that prints full posts is slow and hard to scan, and readers rarely scroll past the first few matches.
Test the search page before you launch it
Run the same four searches every time you change the template, so you can compare.
- Search a phrase that appears only in body text, not in a title. It should still be found.
- Search a word you know is absent, such as a random string. The no-results message and the search form should both show.
- Open page two of a broad search and confirm pagination works.
- Repeat one search on a phone, because the pattern you chose may stack badly.
You know it worked when the body-only phrase returns its post, the nonsense term returns the empty state, page two loads, and nothing overflows on a narrow screen.
Common failure: the saved template does not show
Nine times in ten the template saved and the browser is being served old HTML. Purge the page cache first: on a LiteSpeed host that is the LiteSpeed Cache purge, otherwise your caching plugin or CDN. Then clear the object cache and reload in a private window.
| Symptom | Cause and fix |
|---|---|
| Old layout on the front end, new layout in the editor | Page cache or CDN. Purge, then reload in a private window. |
| Template edits do nothing at all | Classic theme. Edit search.php in the child theme instead. |
| Child theme changes vanish | The file was edited in the parent theme. Move it to the child. |
| Search returns everything | The pre_get_posts filter is missing the is_main_query() check. |
| Layout looks broken after a pattern swap | Open the template, use the three-dot menu, and choose Clear Customizations to start again. |
Where WebJi® fits
WebJi® runs WordPress on Linux plans with cPanel, LiteSpeed and free SSL, from ₹400 a month before 18% GST. Template and query changes are yours to make; the host decides how caching and PHP limits behave around them.
If a template edit still will not appear after a purge, email support@webji.services with the URL and the search term you tested. Support answers 24/7 in Hindi and English, with an average first reply under 60 minutes. The child theme guide covers the safe place to put the code, and WordPress hosting lists the plan limits.
Frequently Asked Questions
How do I customize the WordPress search results page?
In a block theme, open Appearance, Editor, Templates and Search Results, then change the Query Loop pattern and save. In a classic theme, copy search.php into a child theme and edit the copy.
How do I exclude pages from WordPress search?
Add a pre_get_posts filter that sets post_type to post only, with the is_search, is_admin and is_main_query checks. A search plugin can do the same from its settings screen.
Why is my search template change not showing?
A page cache or CDN is serving the old HTML. Purge the LiteSpeed or plugin cache, clear the object cache, and reload in a private window. If nothing changes, the site is on a classic theme using search.php.
Which plugin is best for better WordPress search?
Relevanssi suits sites that need partial-word matching and custom-field indexing on a budget. SearchWP adds live results and weighting. Try one on staging and rebuild its index before you judge the results.
Should search results pages be noindexed?
Usually yes. Search pages produce thin, duplicated URLs. Most SEO plugins can noindex them in one setting, while leaving the posts they link to indexed.
Can I search custom fields in WordPress?
Not with core search. Relevanssi and SearchWP both index custom fields; add the field keys in the plugin settings, then rebuild the index before testing the same phrase again.

