This extension provides Shortcodes that generate both search forms and results pages for SearchWP search engines. It’s useful if you’re not comfortable (or able) to edit theme files directly to implement your search form(s) and results loops.

Plugin Version: 1.8.5
 
WordPress plugin SearchWP Shortcodes

Plugin Features

It is a plugin for WordPress that enables the generation of search forms and search results pages. With its functions, users can create customized search interfaces tailored to their specific needs on WordPress websites. By utilizing shortcode capabilities, it simplifies the process of implementing search functionality without the need for advanced coding skills. This intuitive tool provides a seamless way to enhance the search experience for website visitors.

The functionality of this plugin revolves around the use of shortcodes to embed versatile search forms and results pages effortlessly into WordPress sites. It empowers users to design and tailor the search elements to align with the overall aesthetics and functionality of their websites. By leveraging shortcode parameters, it allows for high flexibility and customization, catering to diverse search requirements efficiently. This adaptability makes it a valuable asset for WordPress site owners looking to optimize search functionalities.

One of its key features is the ability to streamline the search process by providing quick access to relevant information through well-organized search results. It ensures that users can easily navigate through search outcomes and find the desired content promptly. With customizable layouts and styling options, users can maintain consistency with their site design while offering a user-friendly search interface. This enhances the overall user experience and encourages increased engagement on the website.

The plugin offers an array of customization options, including the ability to configure various search parameters and filters to refine search results. This granular control empowers users to adjust settings according to their content structure and user preferences. By incorporating advanced search functionalities within WordPress, it bolsters the overall site usability and aids in presenting content more effectively to visitors. The seamless integration of these features enhances the search capabilities of WordPress sites significantly.

Additionally, SearchWP Shortcodes is designed to be lightweight and optimized for performance, ensuring that it does not weigh down the site or affect loading speeds. Its efficient coding structure and minimal footprint contribute to a smooth user experience without compromising site performance. The compatibility of this plugin with other WordPress tools and themes makes it a versatile solution for enhancing search functionalities across different website setups. Its user-friendly interface and robust feature set position it as a valuable asset for WordPress users looking to elevate their search capabilities.

Specifications:

Release date: 11-10-2020
Last updated: 30-07-2025
Type: Paid
License: GPL 
Subject: Core Enhancements
Compatibility: W5.x W6.x
Includes: Plugin
Language packs: English
Developer: SearchWP

Rating:
4.4874371859296 1 1 1 1 1 (199 Votes)

Download by subscription!

You need to log in on the site and purchase a club subscription!

Share with your friends!

 

SearchWP Shortcodes Guide: Search Forms, Results Pages, and Output Validation

SearchWP Shortcodes is useful when you need to display a SearchWP search form and results without editing your theme files. In this guide, we are not covering the extension as a marketing feature list. Instead, we will walk through a practical implementation: which shortcodes to use, how to connect the form to the right search engine, where to define the results page, how to verify the query variable, and what to do if the results list does not appear.

This guide is intended for site owners, editors, WordPress administrators, and developers who need to add a manageable search interface to a page, widget area, Shortcode block, or a template section where keeping the code footprint minimal makes the most sense. Special attention is given to the engine, var, and target combination, because that is usually what determines whether visitors land on the correct results page.

Throughout this guide, we will rely on the official SearchWP documentation, the WordPress shortcode documentation, and supporting materials on alternatives. Wherever a detail depends on active SearchWP add-ons, the theme, caching, or index settings, the wording is intentionally careful: the extension outputs the interface and the results loop, but the quality of the matches depends on your SearchWP engine configuration and the current state of the index.

SearchWP Shortcodes workflow: form shortcode, SearchWP engine, and page output
The extension works in a straightforward chain: the form shortcode sends the query to the selected engine, and the results shortcode displays matching entries on the chosen page.

Where This Extension Actually Saves Time

SearchWP Shortcodes solves a narrow but highly practical problem: it gives you a set of shortcodes for outputting a search form, results list, result link, excerpt, image, file link, no-results message, pagination, and the total number of matches. It is not a replacement for SearchWP and it does not create its own search index. The extension works on top of SearchWP and uses the search engines you have already built, so the first priority is getting SearchWP itself in order: sources, weights, rules, index, and, if needed, the form or results template.

The most common use case is a dedicated page such as "Knowledge Base Search," "Document Search," "Product Search," or "Support Content Search." In a traditional implementation, a developer would create a theme template, write a PHP form, wire up \SearchWP\Query(), handle the query variable, and output the loop and pagination. SearchWP Shortcodes lets you build the same user flow directly in the WordPress editor: the form submits the query, the results appear below or on a separate page, and the administrator can change the button text, placeholder, number of results, and engine name without editing theme files.

The extension is especially useful if the site already uses SearchWP to improve relevance, but certain pages need a different interface. For example, you might keep the theme's default search in the blog, display a help-only search in the documentation area, and create a separate page for PDF search in the media library. In each case, the workflow is the same: choose the right engine, make sure it indexes the correct sources, insert the form and results with matching engine and var values, then test the output with real queries.

There are also cases where this extension should not be your first choice. If you need a visual form builder with filters, styling controls, and a ready-made results page, newer versions of SearchWP often make it easier to start with Search Forms and Templates. If you only need a modal search in the menu, Modal Search Form is closer to the task. If you want instant suggestions while typing, look at Live Search. SearchWP Shortcodes is the right fit when you need simple, controlled shortcode-based output, not a full interface builder.

What to Check Before Installing and Enabling It

Before installation, do not start by pasting shortcodes into a public page. First, make sure the core SearchWP plugin is installed, activated, and already able to find the content type you need. SearchWP Shortcodes will not fix an empty index, incorrect weights, a disabled source, or a situation where the required content is not included in the search engine at all. If the underlying search does not return the expected entries, the shortcode will accurately reflect that: an empty result set, poor ordering, or content from the wrong section.

Check four things. First, confirm that SearchWP is installed and that you can access its settings page. Second, confirm that the engine is ready: Default Engine is suitable for standard posts, pages, media, and custom post types, while Supplemental Engine is needed when SearchWP must search custom sources outside the standard WordPress loop. Third, check the index status. After changing sources, weights, rules, minimum word length, or shortcode parsing settings, you may need to rebuild the index. Fourth, confirm the output location. The page, widget area, or template must process shortcodes and must not strip them out through theme or builder filters.

Think separately about the query variable. WordPress uses s for the standard search query. SearchWP Shortcodes uses swpquery by default, and you can set your own value through var. That is helpful when a page contains multiple search forms or when you do not want to overlap with the theme's default results. But it also creates one of the most common mistakes: the form submits the query as searchvar, while the results block is reading swpquery. In that case, the form appears to submit correctly and the URL changes, but no results appear because the second shortcode is looking at the wrong variable.

Quick check before publishing: create a test page, insert the form and results, search for a word that is definitely present in indexed content, and inspect the page URL. The value after the question mark should match the var attribute used in the form, results, counter, and pagination.

If the site uses page caching, minification, deferred JavaScript loading, or an aggressive HTML optimizer, do not disable everything at once. First, test a normal form submission without Live Search. If a standard submission works but live suggestions do not, the issue is likely tied to Live Search, JavaScript, caching, or a theme conflict. If even a standard submission fails, start with engine, var, target, the index, and access to the results page.

Installation and the First Post-Activation Check

SearchWP Shortcodes is installed as a SearchWP extension. In a typical workflow, the administrator downloads the extension ZIP from their account or installs it through the SearchWP extensions interface, if that option is available in the current setup. On the WordPress side, it behaves like a standard plugin: upload the ZIP through Plugins - Add New - Upload Plugin, activate it, then go back to SearchWP and confirm that the extension is available.

After activation, do not look for a large standalone settings screen specifically for SearchWP Shortcodes. The value of the extension is in its shortcode set and attributes. The main settings still live in SearchWP: Engines, Search Forms, Templates, Settings, Tools, and Live Search if that extension is also in use. So your first validation step should not be "did I find a new tab," but "does the minimal shortcode setup work on a test page?"

For the first test, create a private or draft page. Insert a Shortcode block and add a simple form for the default engine. Below it, add the results block, a no-results message, and two pagination links. At this stage, do not add CSS, a complex layout, result images, or a separate target page. The simpler the test, the easier it is to see where the chain breaks.

[searchwp_search_form engine="default" var="swpquery" button_text="Search" placeholder="Search the site"]

[searchwp_total_results engine="default" var="swpquery" text="Found: %total% for %query%"]

[searchwp_search_results engine="default" var="swpquery" posts_per_page="10"]
<h3>[searchwp_search_result_link direct="true"]</h3>
[searchwp_search_result_excerpt]
[/searchwp_search_results]

[searchwp_search_results_none]
No results found. Try changing your query.
[/searchwp_search_results_none]

[searchwp_search_results_pagination direction="prev" link_text="Back" engine="default" var="swpquery"]
[searchwp_search_results_pagination direction="next" link_text="Next" engine="default" var="swpquery"]

After saving the page, run three searches. First, search for an exact word from the title of a published post. Second, search for a word from the body content, if that source is included in the engine. Third, search for a word that is definitely absent so you can verify the no-results block. The expected state is this: the form submits the query, the URL contains the selected variable, and both the counter and the results list respond to that same query. If one element reacts while another stays silent, the issue is almost always inconsistent attributes.

Initial SearchWP Shortcodes check in the WordPress editor and on the results page
The best first test is a dedicated page with the bare minimum: form, counter, results, no-results message, and simple pagination.

How the Form, Query Variable, and Results Page Work Together

The key thing to understand about SearchWP Shortcodes is that the form and the results are not one magic block. The extension gives you separate pieces that must be connected correctly. The form creates the HTML form and submits the query. The results block reads the query value from the specified variable. The counter reads that same variable as well. Pagination must use the same engine and the same variable, otherwise the next results page can lose the query context.

The target attribute controls the form action. If you do not set it, the form usually submits to the current permalink. That is convenient when the form and the results are on the same page. If the form lives in the header, sidebar, or a landing page, but the results should open in a separate section, set target to the results page URL. Just make sure that page contains the results shortcodes with the same engine and var values.

The engine attribute selects the SearchWP engine. By default, it uses default, but for certain use cases it is better to create an additional engine. For example, docs_search might search only the knowledge base and PDFs, while product_search might search products and attributes. The shortcode must use the engine's internal name, not its display title. SearchWP shows that name next to the engine label in a monospace format, so it is best to copy it exactly as shown.

The var attribute defines the GET variable name. For a single search, leaving swpquery is perfectly fine. For multiple independent searches on the same page, it is better to separate variables, for example docsquery for documents and faqquery for questions. That way, one results block will not react to another block's query. But separation requires consistency: if the form uses var="docsquery", the results, counter, and pagination must use that exact same attribute.

Typical Setup: Header Form, Separate Results Page

Imagine a site with a knowledge base. You want a compact form in the header, but the results should appear on /help-search/. On the page where the form is placed, use only the form:

[searchwp_search_form engine="docs_search" target="https://example.com/help-search/" var="docsquery" button_text="Search" placeholder="Search the knowledge base"]

On the /help-search/ page, place the results block, counter, empty state, and pagination:

[searchwp_total_results engine="docs_search" var="docsquery" text="Items found: %total%"]

[searchwp_search_results engine="docs_search" var="docsquery" posts_per_page="12"]
<h3>[searchwp_search_result_link direct="true"]</h3>
[searchwp_search_result_excerpt]
[/searchwp_search_results]

[searchwp_search_results_none]
No knowledge base items match this query.
[/searchwp_search_results_none]

[searchwp_search_results_paginate_links engine="docs_search" var="docsquery" type="list"]

The validation is simple: submit a search from the header, confirm that /help-search/ opens, and check that the URL contains ?docsquery=.... If the page opens but no results appear, do not start by debugging the form. Check the results block on the target page. If results appear only on the current page, target is either missing or pointing to the wrong place. If results appear but pagination drops the query, check the pagination var.

The engine var target relationship in SearchWP Shortcodes
These three attributes must line up correctly: engine selects the engine, var carries the query, and target points to the output page.

Search Form via searchwp_search_form: Settings That Affect Behavior

The searchwp_search_form shortcode outputs a search form for the selected engine. In practice, think of it as the entry point into the search flow. The form includes user-facing elements such as the placeholder, button text, and button visibility. It also includes behavioral settings such as the engine, query variable, and submission URL. And if the related extension is active, it can also control Live Search behavior.

For most sites, the priority is not making the form look impressive, but making it clear and predictable. The placeholder should define the search scope: "Search the knowledge base," "Find a document," "Search the catalog." The button text is usually best kept short: "Search," "Find," "Show Results." If the button is hidden through hide_button, make sure it is obvious that the form can be submitted with Enter, and confirm that the theme does not break form accessibility.

When to Use live_search

The live_search attribute lets you explicitly enable or disable Live Ajax Search for a specific form, regardless of the global setting. That is useful when one search should offer suggestions while typing, while another should lead to a full results page. For example, you might enable live suggestions in the header for quick jumps, but keep a standard submission with pagination and detailed excerpts on the documentation page.

Do not turn on live search everywhere by default. It creates a different user experience: visitors see a dropdown before submitting the form, and may not go to the results page at all. That works well for a compact knowledge base. For a large catalog with filters, long excerpts, and pagination, a standard results page is usually better, or you may want to use Live Search only as a secondary assist. If live_search="true" is enabled and the regular results page works but suggestions do not, check your Live Search settings, JavaScript caching, and theme conflicts.

Should You Hide the Submit Button?

In versions of the extension that support hide_button, you can output the form without a button. That can work in a compact header or an interface where the design clearly suggests typing a query. But for a help page, document search, or an audience using different devices, keeping the button is usually the safer choice. A visible button helps users understand that the form is submitting a query to SearchWP, not just filtering the current list.

If you do hide the button, verify three things: the form submits with Enter, the input field has a visible keyboard focus state, and a result message appears after submission. Do not rely on appearance alone. Very often, the issue is not with SearchWP Shortcodes itself but with the theme changing the field height, removing visible focus, or overriding default form styles.

Configuring the Placeholder and Button Text

The placeholder should not replace a proper form label, but within a shortcode it is the fastest way to clarify what the search covers. On a documentation page, use "Search the documentation"; in a media library, "Find a PDF or file"; in a store, "Find a product or SKU" if the engine really indexes that data. The button text should not overpromise. "Search" is more honest than "Show the perfect result," because the output still depends on the index and relevance settings.

Shortcode Map: What Each Piece Does

It helps to think of SearchWP Shortcodes as a toolkit of small parts rather than one large builder. Each part handles a specific segment of the user flow. The form receives the query. The results container repeats its markup for each matched item. Nested shortcodes insert the current result's title, excerpt, image, or permalink. Separate elements handle the empty state, result count, and navigation. This approach gives you flexibility, but it also requires precision: if you place a shortcode in the wrong location, it can end up outside the result context.

The single most important rule is not to use nested result shortcodes outside searchwp_search_results. For example, searchwp_search_result_excerpt only makes sense inside the results loop, where a current matched item exists. If you place it separately on the page, it has no context to read from. The same applies to the current result link, image, and permalink. Outside the results container, you should place the form, counter, empty state, and pagination.

Practical Purpose of SearchWP Shortcodes
Shortcode Where to Use It What to Check
searchwp_search_form Before the results, in the header, in a widget, or on a dedicated search landing page. Matching engine and var, plus the correctness of target.
searchwp_search_results On the page where the list of matched content should appear. The presence of the closing shortcode and the markup for a single result item inside it.
searchwp_search_result_link Only inside searchwp_search_results, usually in the result title. The behavior of direct, especially for attachments and media files.
searchwp_search_result_excerpt Only inside a result item, next to or below the title. Excerpt quality, whether highlighting is enabled, and mobile readability.
searchwp_search_results_none After the results block to handle the empty state. The text should offer a next step, not just say that nothing was found.
searchwp_total_results Above the results list or next to the form. The same engine and var used by the results block.
searchwp_search_results_pagination For simple "back" and "next" links. The direction value, the link text, and whether the search query is preserved.
searchwp_search_results_paginate_links For a page-number list using WordPress paginate_links parameters. The output type, link accessibility, and whether the query variable is preserved.

How Not to Lose the Result Context

Think of searchwp_search_results as opening a miniature loop. Everything inside it repeats for each matched item. If there is a title inside, each result gets its own title. If there is an excerpt inside, each result gets its own excerpt. If you accidentally place a large block of general instructions inside it, those instructions will repeat as many times as there are results. That is why general copy, hints, and the empty state should stay outside the loop, while only single-result markup belongs inside it.

There is another detail to keep in mind with nested markup: some editors and page builders like to "fix" HTML automatically. They may insert extra paragraphs, close a tag too early, or move part of the code into another block. If the output breaks after saving, check whether the shortcode was split across multiple visual blocks. In the block editor, it is safer to keep the entire result fragment inside one Shortcode block, especially while you are testing behavior.

Choosing Between searchwp_search_result_link and searchwp_search_result_permalink

searchwp_search_result_link outputs a link using the current result title as the link text. That is the best option for a standard results list: users see the entry title and open it. searchwp_search_result_permalink outputs the permalink as visible link text. It is useful less often, for example when a results page needs to display direct document URLs, technical links, or a file list. In a normal knowledge base, showing the raw permalink usually makes the results harder to scan, especially on mobile.

The direct attribute matters most for media. If the site searches PDFs, the administrator needs to decide what the correct destination should be: the WordPress attachment page or the file itself. For documentation, the direct file is often more convenient if the user wants to download or read the PDF immediately. For a media archive, the attachment page may be more useful if it includes a description, date, category, and related content. Validate this with an actual click, not just by seeing that the link looks correct.

When to Display a Result Image

searchwp_search_result_image adds a thumbnail for the current result. It is not a required part of a good search experience. In a product catalog, portfolio, or template library, an image can speed up selection. In legal documentation, a technical knowledge base, or a PDF list, it may be distracting. If you enable thumbnails, also test the output without them: the card should not collapse or leave an empty frame behind. On a page with mixed content types, it is usually better to have a clean text-based fallback that does not depend on an image.

The image size is set through the size attribute. Do not choose a large image just because it makes the result card feel richer. Search is a navigational interface, not a gallery. Oversized images slow down scanning and can hurt the mobile experience. Start with a small or medium size, then check whether the thumbnail genuinely helps users decide. If it does not, remove it and improve the excerpt instead.

The Results Page: Nested Shortcodes, Excerpts, Images, and the Empty State

The searchwp_search_results shortcode matters because it is not self-closing. Inside it, you need to place the markup for a single result item: link, excerpt, image, permalink, or extra HTML wrappers. Think of it as a mini result template embedded directly in the editor. If the closing shortcode is missing, if nested shortcodes are placed outside it, or if a page builder alters the structure, the output can become unpredictable.

Start with a simple list: linked title and excerpt. Once that works, add a result image through searchwp_search_result_image, a direct file URL through searchwp_search_result_permalink, or an extra wrapper for a grid layout. Keep in mind that an image will only appear if the result has a thumbnail or if the selected size exists for that post type. For PDFs and attachments, link behavior matters especially: the direct attribute on the result link and permalink lets you decide whether the visitor should go straight to the file or to the attachment page.

Basic Markup for a Single Result

[searchwp_search_results engine="docs_search" var="docsquery" posts_per_page="10"]
<article class="swp-result-card">
  <h3 class="swp-result-title">[searchwp_search_result_link direct="true"]</h3>
  <div class="swp-result-excerpt">[searchwp_search_result_excerpt]</div>
</article>
[/searchwp_search_results]

This markup is a safe starting point: it does not require theme edits and it remains readable even if extra styles are turned off. If you want to add a thumbnail, use it only where it actually helps users orient themselves. In a knowledge base, it is often unnecessary, while in a product catalog or portfolio it can speed up selection.

Result Count and a Useful Empty State

searchwp_total_results outputs the total number of matches and supports text placeholders such as %total% and %query%. It is a good way to show users that the search really ran. But the counter must be tied to the same engine and variable as the results. If the counter shows one thing and the list shows another, the cause is almost always mismatched attributes.

The searchwp_search_results_none block is not just there to say "nothing found." It should tell the user what to do next: change the query, remove quotation marks, check the keyboard layout, try a shorter term, browse to a category page, or contact the administrator if the site is private. Do not turn the empty state into a dead end. On a help site, you might add "Try searching by function name or error code"; in a store, "Check the SKU or part of the product name."

Pagination: Two Buttons or a Page List

The extension supports two approaches. searchwp_search_results_pagination outputs separate "back" and "next" links through the direction attribute. That works well for a simple list. searchwp_search_results_paginate_links uses WordPress paginate_links parameters and is better when you need a numbered page list. In both cases, keep engine and var identical. Pagination without the correct query variable may look like a working link, but after clicking it the user can end up with empty or reset results.

SearchWP Shortcodes results markup with link, excerpt, image, and pagination
The results are assembled like a template: inside the results container, you place the link, excerpt, image, and navigation elements.

Separate Engines: When default Is No Longer Enough

For a typical site with posts and pages, starting with default is fine. But SearchWP becomes much more powerful when different areas of the site get their own engines. SearchWP Shortcodes makes those setups easier because you can output a form and results for a specific engine directly on the page that needs them. This is especially useful for documentation, private sections, content libraries, media search, and sites with multiple content types.

Default Engine is special because it is tied to native WordPress search and works within what WordPress expects from the standard loop. Supplemental Engine is needed when you want to search sources that do not fit the usual WP_Post model or when you need a separate rule set. SearchWP documentation notes that additional sources may require a custom output implementation, and that is where shortcodes help you avoid writing a manual PHP loop at the first stage.

Example: Searching a Document Library

Suppose the site has a section with how-to content and PDF files. The goal is to give visitors a dedicated search page for those materials without mixing the results with regular news posts. In SearchWP, you create a docs_search engine, add the required sources, configure the weights for titles, content, excerpts, custom fields, and media, and save the engine. Once the engine is saved, the index must be ready. Only then should you insert a form on the page with engine="docs_search".

You should test this type of setup with a sequence of queries, not just one. First, search for a word from a document title. Then search for a word from page content. Then search for a word that exists only inside a PDF, assuming media and document content are actually included and processed. After that, test a query that should not match anything. This helps you see exactly where the engine boundary is: the form works, but the source is not indexed; the source is indexed, but weighted too low; the PDF is found, but the link goes to the wrong place; the results are correct, but the empty state is too generic.

Multiple Forms on the Same Page

If a page includes two searches, for example one for articles and one for files, do not use the same query variable for both. Otherwise, submitting one form can trigger both results blocks. Here is a safer pattern:

[searchwp_search_form engine="articles_search" var="articlequery" button_text="Find Article"]
[searchwp_search_results engine="articles_search" var="articlequery" posts_per_page="5"]
<h3>[searchwp_search_result_link direct="true"]</h3>
[searchwp_search_result_excerpt]
[/searchwp_search_results]

[searchwp_search_form engine="files_search" var="filequery" button_text="Find File"]
[searchwp_search_results engine="files_search" var="filequery" posts_per_page="5"]
<h3>[searchwp_search_result_link direct="true"]</h3>
[searchwp_search_result_excerpt]
[/searchwp_search_results]

This approach also makes debugging easier. The page URL immediately shows which form was submitted. If filequery appears in the URL but the articles block updates, one of the attributes is mismatched somewhere. If the URL contains both parameters, check whether the theme is submitting both forms together because of nested markup or an incorrectly closed container.

Practical Example: A Knowledge Base Search Page

Let us walk through a real setup that you can adapt for documentation, a learning portal, or product support. The goal is to create a page where visitors enter a query, see the number of matching items, get a list with linked titles and contextual excerpts, and understand what to do next if nothing is found. The search should run only against a preconfigured knowledge_base engine, not the entire site.

Goal and Preparation

The goal is not just to display a search field, but to build a predictable results page. Before inserting any shortcodes, you should already have published knowledge base content, a SearchWP engine configured with the correct sources, an updated index, and a dedicated page such as /knowledge-search/. If your help articles use a custom post type, make sure it is included in the engine. If you use categories or custom fields for prioritization, check the weights and rules.

On the page itself, add a short introductory paragraph for the user. It can explain that it is best to search by function name, part of an error message, or a keyword. Then insert a Shortcode block and add the form. After that, add the counter, results, empty state, and pagination. At this stage, do not mix the new search with latest-articles blocks or filters, so you can validate the clean output first.

Setup Steps

  1. Create or verify the knowledge_base engine in SearchWP and include the required sources.
  2. Save the engine settings and wait until the index is ready, especially if you added new sources or changed the minimum word length.
  3. Create the results page and insert the form with target pointing to that same page, or leave the form submitting to the current URL.
  4. Add searchwp_total_results so users can see that the query was processed.
  5. Add searchwp_search_results with clean markup for a single result item.
  6. Add searchwp_search_results_none with a practical hint instead of a flat no-results message.
  7. Add pagination if the result set may extend beyond one viewport.

Ready-to-Use Insert for a Test Page

[searchwp_search_form engine="knowledge_base" var="kbquery" button_text="Search" placeholder="Search the knowledge base"]

[searchwp_total_results engine="knowledge_base" var="kbquery" text="Items found: %total%"]

[searchwp_search_results engine="knowledge_base" var="kbquery" posts_per_page="8"]
<article class="kb-search-result">
  <h3>[searchwp_search_result_link direct="true"]</h3>
  <p>[searchwp_search_result_excerpt]</p>
</article>
[/searchwp_search_results]

[searchwp_search_results_none]
Nothing matched this query. Try searching by function name, part of the error message, or a shorter phrase.
[/searchwp_search_results_none]

[searchwp_search_results_paginate_links engine="knowledge_base" var="kbquery" type="list"]

How to Validate the Output

Start by searching for a word that definitely appears in an article title. Then test a word from the middle of a long body of text. If term highlighting is enabled in SearchWP settings, pay attention to the excerpt: it should help explain why the result was matched. After that, test a few short terms. If the site is supposed to find one- or two-character terms, that requires a separate SearchWP setting and an index rebuild. Finally, open the second results page if one exists and make sure the query has not been lost.

Expected outcome: the user enters a query, stays on a clear results page, sees the number of matching items, gets clickable titles and excerpts, and receives a useful hint when the result set is empty.

If you want the form in the header instead of only on the page, move the form to the appropriate area and point target to the results page. Do not copy the entire results block into the header. The header should be the entry point, while the results page should provide enough room for the counter, excerpts, pagination, and empty state.

Practical SearchWP Shortcodes example for a knowledge base search page
This practical setup is built around a single user task: query, results, relevance check, and a clear empty state.

Styling the Output Without Editing Plugin Files

SearchWP Shortcodes outputs HTML markup, while the appearance mainly depends on your theme and any wrapper classes you add. Do not edit SearchWP, extension, or active theme files directly. For small improvements, use classes in your result markup and place the CSS somewhere safe: a child theme, the theme's additional CSS area, or a snippet plugin if that is already part of your workflow.

The cleanest approach is to add your own classes to the result wrapper inside searchwp_search_results. That way, the styles apply only to that page or block rather than every search form on the site. The example below does not change the search behavior, interfere with queries, or depend on SearchWP internal classes. It simply improves the readability of the results list.

.kb-search-result {
  margin: 0 0 18px;
  padding: 18px;
  border: 1px solid #e3e7ef;
  border-radius: 8px;
  background: #ffffff;
}

.kb-search-result h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  line-height: 1.35;
}

.kb-search-result p {
  margin: 0;
  color: #4b5563;
}

Validation after adding CSS is simple: the result should remain clickable, the excerpt should stay readable on a mobile screen, and the spacing between cards should not make the page feel empty. If the styling breaks the output, remove the CSS entirely or temporarily rename the class in the markup. That gives you a fast rollback without touching the extension itself.

If you use Live Search, do not mix the styles for the regular results page with the styles for the dropdown suggestions. Live Search has its own display settings and templating system. A standard results page and a dropdown suggestion list serve different purposes: the first helps users review a list, while the second helps them jump quickly to a likely match. It is better to style them separately.

Compatibility with the Block Editor, Theme, Caching, and Live Search

In the WordPress block editor, shortcodes have their own Shortcode block. It is more reliable than inserting them into a normal paragraph because the editor does not try to convert the content into visual blocks. If you use a page builder, look for an element that explicitly supports shortcodes. Not all text widgets handle nested shortcodes and HTML markup equally well, especially when searchwp_search_results contains multiple lines of HTML.

The theme affects search in two ways. First, visually: form styles, buttons, result cards, and pagination. Second, functionally: the theme's standard search template may intercept native WordPress search, but SearchWP Shortcodes is more commonly used on a separate page where the results are rendered by the shortcode itself. If the form submits to the standard WordPress search page when you expected a dedicated SearchWP page, check target. If you are using Default Engine and the theme's native results output, make sure that was an intentional choice.

Page caching should not normally break a GET form submission, but it can hide changes to markup, CSS, or JavaScript. After changing shortcodes, clear the page cache and the builder cache if one exists. If Live Search is enabled, also check script minification and file combining. According to the official documentation, Live Search can automatically enhance forms created through get_search_form(), while specific forms can use attributes and configuration options. With SearchWP Shortcodes, the simplest path is to first get the regular results output working correctly and only then enable live suggestions.

When to Enable Parse Shortcodes

The SearchWP Parse Shortcodes setting does not affect the output of SearchWP Shortcodes itself. It affects the indexing of content generated by shortcodes inside posts. If your site stores important text in shortcode-generated content, SearchWP may need to process that text during indexing. But enabling this setting can change both the volume and nature of indexed text, so test it in a staging environment or at least against a limited set of queries. After changing it, you may need to rebuild the index.

Minimum Word Length and Short Queries

If users search for short terms such as "AI," "UX," "3D," or "SKU," the standard index limits may not return the expected matches. SearchWP includes a setting for removing the minimum word length restriction, but enabling it requires a fresh index. On a page built with SearchWP Shortcodes, this can look like a shortcode problem: the form is there, the query is submitted, but the short term is not found. In reality, the output is working and the index simply does not contain the required token. That is why short queries should always be tested separately.

Common SearchWP Shortcodes Issues and How to Diagnose Them

The fastest way to troubleshoot is to follow the chain: the query enters the form, the variable appears in the URL, the results block reads that same variable, the engine includes the right source, the index is ready, and the theme is not hiding the output. That order is more efficient than randomly changing CSS, cache settings, and relevance rules all at once.

The Form Is Visible, but No Results Appear After Submission

Symptom: the user enters a query, the page reloads, but the results list is empty or does not appear at all. Possible causes include different var values in the form and results, an incorrect engine, a target page that does not contain the results block, an unfinished index, or a query tied to a source that is not included in the engine.

Check the URL after submission. If it contains ?kbquery=... but the results are configured with var="swpquery", fix the attributes. If the variable matches, temporarily switch the engine to default and search for a normal post. If Default Engine works, the issue is in the supplemental engine or its index. If it does not work either, check whether shortcodes are being processed on that page.

Pagination Resets the Query or Opens an Empty Page

Symptom: the first results page is correct, but clicking "Next" or a page number produces an empty result set. The cause is often that pagination is using a different var or is missing engine. Another possibility is that caching or the page builder is altering the generated links.

First, make sure pagination uses the same attributes as the results block. Then inspect the second-page URL: the search query should still be present. If you use searchwp_search_results_paginate_links, do not add extra parameters until you have confirmed that the basic pagination works.

The Result Count Does Not Match the List

Symptom: the counter shows matches, but the list is empty, or the reverse. This usually means searchwp_total_results and searchwp_search_results are looking at different engine and var pairs. Another possibility is that one block is on the page receiving the query, while the other is inside a tab or builder area where the shortcode is not being executed.

For troubleshooting, place the counter directly above the results and keep only one engine in use. If the mismatch disappears, add the other elements back one at a time. That makes it much easier to find the block that is still using an old variable or was copied from another page.

Short Terms, SKUs, or Abbreviations Are Not Found

Symptom: long words are searchable, but short terms are not. In SearchWP, this is often tied to the minimum indexed word length. Check the SearchWP settings related to minimum length, and remember that changing this requires a full index rebuild. Do not try to fix it with CSS or by changing the search form shortcode.

Live Search Behaves Differently from the Regular Results Page

Symptom: a standard form submission shows results, but suggestions while typing are empty or appear in the wrong place. Check the Live Search settings: whether it is enabled, the minimum length, the dropdown position, the maximum result count, style loading, and the engine configuration. If the form is created with a shortcode, you can explicitly set live_search="true" or live_search="false" so it does not depend on the global setting.

The Excerpt Looks Strange or Does Not Show the Matched Term

Symptom: a result is found, but the description does not help explain why. SearchWP includes a term-highlighting setting that generates a contextual excerpt and wraps matched words in mark.searchwp-highlight. If highlighting is disabled, the excerpt may just be the standard post excerpt. If it is enabled but looks poor, check the excerpt length, the source content, HTML inside the post, and the theme styles for the mark tag.

Old Results Stay the Same After Changing the Engine

Symptom: you added a source, changed weights, or enabled shortcode parsing, but the output did not change. Check whether the index needs to be rebuilt. SearchWP tools include diagnostics that help you inspect indexed tokens and non-indexed entries. If a specific item never made it into the index, SearchWP Shortcodes will not be able to display it in the results.

SearchWP Shortcodes diagnostics: query variable, engine, index, and pagination
Troubleshooting should follow the full chain: URL and variable, matching attributes, engine, index, output, cache, and Live Search.

Validating the Output Before Publishing

Before publishing, run a short validation checklist of your own. It does not need to take long, but it will catch most unpleasant mistakes. Do not just check that "the form searches for something." Validate the full user flow: input, submission, URL, counter, list, empty state, pagination, mobile display, and repeat search behavior.

Start with test queries. Pick one word from a title, one from the body content, one from a custom field or document if that source is included, and one query that should return nothing. Then test different letter casing, a quoted phrase, a short term, and a misspelled word if partial matching or similar behavior is enabled. Do not promise users behavior you have not actually verified. If the site is not configured for short terms, do not tell users "search by SKU" until SKU search has been tested.

Then check the interface. On mobile, the field and button should fit the width of the screen, and the result cards should not collapse into a narrow column with clipped headings. The clickable area of each link should feel clear. The empty state should do more than say "no results" - it should help the user refine the query. If result images are enabled, test posts without thumbnails. If you output direct file links, make sure they open in the expected way.

The final step is rolling back questionable changes. If you added CSS, temporarily remove it and confirm that the search behavior still works without styling. If you enabled Live Search, turn it off and test the standard submission again. If you changed the engine, switch the test page back to Default Engine and compare the behavior. This kind of control makes it much easier to pinpoint the cause: shortcodes, engine, index, styling, or extra behavior.

How to Roll It Out on a Live Site Without Unnecessary Risk

SearchWP Shortcodes can look like a harmless change: paste a few lines into the editor, save the page, and you have search. In practice, it affects site navigation, which means it should be deployed like a small release. You do not need a complex process, but it helps to decide in advance where the entry point will be, which materials should be searchable, how visitors will return to the results, and how the administrator can quickly disable the new search if something goes wrong.

Start with a non-public page. Even if the final form belongs in the header, build it first on a test page together with the results. That lets you validate the shortcodes without involving menus, caches, global templates, or the mobile header. Once the logic is working, move only the form into the header and keep the results on a separate page. That separation is easier to debug: if the test page works but the header does not, the problem is in the insertion point, not in SearchWP or the engine.

Launch Plan for an Editor or Administrator

  1. Write down the engine name and query variable in a short note attached to the task, for example engine=knowledge_base and var=kbquery.
  2. Create a test page and insert the full shortcode set: form, counter, results, empty state, and pagination.
  3. Validate the output with five real queries: an exact title, a word from the body text, a term from the required field, a short term, and a query that should return nothing.
  4. Clear the cache only after the logic works without styling, so you do not hide the problem behind an outdated page.
  5. Add CSS or result wrappers gradually, checking the output after each change.
  6. Move the form into the public location and point target to the validated results page.
  7. After publishing, run a search as a normal visitor in a private browser window.

This sequence may seem longer than necessary, but it saves time. SearchWP Shortcodes problems are rarely mysterious if you have a control page. Without it, an administrator only sees that "search is broken" and starts changing the engine, cache, blocks, CSS, and theme settings all at once. With a control page, it becomes much easier to identify which part of the chain changed after the move.

What Counts as a Finished Result

A finished search setup is not just a form that returns some kind of entries. For a documentation page, a finished result means the top positions actually match the query, the excerpts explain the match, the empty state helps users rephrase their search, and pagination preserves context. For file search, it matters that the link opens the expected file or attachment page. For a store, it matters that users do not land on a general blog post instead of a product when the form is meant to search the catalog.

Define those criteria before publishing. For example: "searching by tutorial title shows that tutorial in the top three," "searching by product SKU finds the product page," "searching for a nonexistent word shows a helpful prompt," "the second results page preserves the query." These are much easier to test than the abstract idea that "search got better." They also help the team distinguish an output issue from a relevance issue.

How to Roll Back the Change

The fastest rollback is to remove the public entry point, not to remove SearchWP Shortcodes. If the form is in the header, temporarily remove it from the menu, widget, or template. The results page can remain as a draft or stay out of navigation while you fix the settings. If the issue is in CSS, remove only the CSS. If the issue is in Live Search, disable live_search for that form and keep the standard submission. If the issue is in the new engine, temporarily switch the test form back to default to confirm the basic setup still works.

Do not delete the index or change global SearchWP settings in a panic. The index, weights, and sources may affect other search forms on the site. If the new search is built on a separate Supplemental Engine, it is safer to disable the page or form first, then calmly review the engine, the source list, and the diagnostics. This matters even more in a production project: header search, documentation search, and store search may all use different configurations while living inside the same SearchWP installation.

SearchWP Shortcodes FAQ

Can I use SearchWP Shortcodes without the main SearchWP plugin?

The extension is designed to work with SearchWP and its search engines. It is not a standalone replacement for WordPress search. If SearchWP is not configured, or if the required engine does not include the right sources, the shortcodes will not be able to show the expected results.

Why is it sometimes better to place the form and results on different pages?

A form in the header or sidebar should stay compact, while a results page needs room for the counter, excerpts, empty state, and pagination. The split is handled through target: the form submits the query to the page where the results block is placed with the same engine and var.

What is the most important thing to check after inserting the shortcodes?

Check that engine and var match across all related shortcodes, that the SearchWP index is ready, and that results appear on the target page. Then test an empty query, a no-results query, pagination, and the mobile view.

Can I display multiple searches on one page?

Yes, but each search should ideally use its own var value and, if needed, its own engine. Otherwise, a single query can trigger multiple results blocks or throw off the counter.

Why are short queries like "AI" or "SKU" not found?

The cause is usually not SearchWP Shortcodes itself, but the SearchWP index settings. If short words need to be searchable, check the minimum word length setting and rebuild the index after changing it. Then test short queries separately.

Do I need Live Search for SearchWP Shortcodes to work?

No. A standard form submission and a results page work on their own. Live Search is only needed for instant suggestions while typing. It can be enabled or disabled for a specific form through the live_search attribute if the related extension is active.

Can I change the result HTML inside searchwp_search_results?

Yes, that is the whole point of the nested shortcode. You define the markup for one result item between the opening and closing searchwp_search_results tags. The main thing is not to forget the closing shortcode and not to move nested elements outside the results container.

When is it better not to use this extension?

If you need a visual form and template builder, start with Search Forms and Templates. If you only need modal search in the menu, look at Modal Search Form. If the entire task is instant suggestions without a dedicated results page, Live Search or another specialized Ajax search tool will usually be a better fit.

When SearchWP Shortcodes Is the Right Choice

SearchWP Shortcodes is worth using when you already have SearchWP configured and need to quickly output a separate search workflow without editing theme files. The strongest use cases are a knowledge base, document search, a dedicated product or content search, a help page, a private catalog, and multiple independent forms on one page. The extension gives you control over where the form submits, which engine is used, which variable carries the query, and how each result item is rendered.

Do not expect the shortcode itself to improve relevance or fix the index. Its job is to connect the form, the query, and the output cleanly. So the best working order is this: configure the SearchWP Engine, verify the index, build a minimal shortcode-based page, test real queries, and only then add styling, Live Search, or more complex result markup.

If that is the setup you need, then after checking compatibility and planning the rollout, you can download SearchWP Shortcodes and test the extension on a site copy or a separate test page. Start with the minimal form-and-results connection, document the selected engine and var, and expand the output only after the basic results behave predictably.

By OceanTheme.org Editorial Team

 

You are not logged in to post comments.