Shortcodes
Current version: 1.8.5
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.
After activating Shortcodes, the following will be available to you:
| Shortcode | Attribute(s) | 
|---|---|
| searchwp_search_formOutputs a search form for a specific search engine | target— The form action (Default is the existing permalink)engine— Search engine name (Default isdefault)var— The search query variable name (Default isswpquery)button_text— Form button text (Default isSearch)hide_button— Either “true” or “false”, hides the search form submit buttonplaceholder— Form input placeholder text (Default isSearch)live_search— Either “true” or “false”, force enable/disable Live Ajax Search for this form, ignoring the value of the global “Enable Live Search” setting | 
| searchwp_search_resultsOutputs the list of search results once a search has been submitted | engine— Search engine name (Default isdefault)var— The search query variable name (Default isswpquery)posts_per_page— How many posts per page to displayNote that this is not a self-closing Shortcode, the markup for each search result should be nested inside, see the sample below for example | 
| searchwp_search_result_linkOutputs a link to the current search result with the text of the result’s title | direct— Either “true” or “false”, when true link directly to the permalink, if it’s an attachment link directly to it’s URL, not the parent page | 
| searchwp_search_result_excerptOutputs the excerpt for the current search result | None | 
| searchwp_search_results_noneOutput if no search results were found | None Note that this is not a self-closing Shortcode, the markup for each search result should be nested inside, see sample below for example | 
| searchwp_search_results_paginationOutputs pagination of search results | engine— Search engine name (Default isdefault)direction— Either “prev” or “next”link_text— The text to use in the linkvar— The search query variable name (Default isswpquery) | 
| searchwp_search_results_paginate_linksOutputs paginated links for search results | engine— Search engine name (Default isdefault)var— The search query variable name (Default isswpquery)In addition to the above, arguments from paginate_linksare also supported. | 
| searchwp_search_result_imageOutputs Featured Image for the current result | size— Image size (Default isthumb) | 
| searchwp_search_result_permalinkOutputs permalink for the current result with the text of the result’s permalink | direct— Whether to link directly to Media files (Default is'true') | 
| searchwp_total_resultsOutputs a total number of results for the current search | engine— Search engine name (Default isdefault)var— The search query variable name (Default isswpquery)text— The text to use alongside the number of results. Supports%total%and%query%placeholders for precise formatting.[searchwp_total_results text="Found %total% results for %query%"]converts to “Found 0 results for example search”. | 
Here is a sample of a comprehensive implementation of Shortcodes that searches a supplemental engine with a name of my_test_engine :
You can customize the attributes as per the table above.
Changelog
1.8.5
- [Fix] Label FOR attribute not matching the input ID when a custom search variable is used.
1.8.4
- [New] Added option to hide submit button.
1.8.3
- [New] Compatibility with Live Ajax Search.
- [Improvement] The searchwp_total_resultsshortcode supports text customizations.
1.8.2
- [Fix] Prevent Error due to Shortcode recursion.
- [Update] Updated updater.
1.8.1
- [Fix] posts_per_pageattribute not reflected when using SearchWP 4.
1.8.0
- [New] New Shortcode searchwp_search_results_paginate_linksfor paginated links.
- [New] New Shortcode searchwp_search_result_imagefor result Featured Image output.
- [New] New Shortcode searchwp_search_result_permalinkfor result permalink output.
- [Update] Updated updater.
1.7.0
- [New] Compatibility with SearchWP 4.
1.6.1
- [Fix] Issue with handling quotes.
1.6
- [New] New Shortcode: searchwp_total_resultsto output the total number of search results.
- [New] Adds placeholderargument tosearchwp_search_formShortcode.
- [Update] Updated updater.
1.5.4
- [Fix] Additional checks to prevent edge case function redeclaration.
- [Update] Updated updater.
1.5.3
- [New] New filter: searchwp_shortcodes_engine.
- [New] New filter: searchwp_shortcodes_paginate_links.
- [New] New filter: searchwp_shortcodes_pagination_prev.
- [New] New filter: searchwp_shortcodes_pagination_next.
- [Update] Updated updater.
1.5.1
- [New] New Shortcode [searchwp_search_result_excerpt_global].
- [New] New Shortcode [searchwp_search_result_excerpt_document].
- [Improvement] Refined escaping so as to better pair with Term Highlight.
1.5
- [Improvement] Support for automatic updates based on your SearchWP license key.
1.2.1
- [New] Added a number of actions during output.
1.2
- [Change] Allow GET variable to be set in Shortcode attribute, among other things.
1.1
- [Fix] Fixed an issue where attributes weren't passed to the Shortcode callback.
1.0
- Initial release.
 
					

