SearchWP

Shortcodes

Current version: 1.8.2 View Changelog

Download available with active license

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_form
Outputs a search form for a specific search engine
target — The form action (Default is the existing permalink)
engine — Search engine name (Default is default)
var — The search query variable name (Default is swpquery)
button_text — Form button text (Default is Search)
searchwp_search_results
Outputs the list of search results once a search has been submitted
engine — Search engine name (Default is default)
posts_per_page — How many posts per page to display Note that this is not a self-closing Shortcode, the markup for each search result should be nested inside, see sample below for example
var — The search query variable name (Default is swpquery)
searchwp_search_result_link
Outputs a link to the current search result
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_excerpt
Outputs the excerpt for the current search result
None
searchwp_search_results_none
Output if no search results were found
NoneNote 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_pagination
Output pagination of search results
engine — Search engine name (Default is default)
direction — Either “prev” or “next”
link_text — The text to use in the link
var — The search query variable name (Default is swpquery)
searchwp_search_results_paginate_links
Output paginated links for search results
engine — Search engine name (Default is default)
var — The search query variable name (Default is swpquery)

In addition to the above, arguments from paginate_links are also supported.

searchwp_search_result_image
Output Featured Image for the current result
size — Image size (Default is thumb)
searchwp_search_result_permalink
Output permalink for the current result
direct — Whether to link directly to Media files (Default is 'true')

Here is a sample of a comprehensive implementation of Shortcodes that searches a supplemental engine with a name of my_test_engine :

<h3>Search Form</h3>
[searchwp_search_form engine="my_test_engine" target="http://example.com/supplemental-search/" var="searchvar" button_text="Find Results"]
<div class="search-results-wrapper">
Total Results: [searchwp_total_results engine="my_test_engine" var="searchvar"]
[searchwp_search_results engine="my_test_engine" var="searchvar" posts_per_page=2]
<h2>[searchwp_search_result_link direct="true"]</h2>
[searchwp_search_result_excerpt]
[/searchwp_search_results]
</div>
<div class="no-search-results-found">
[searchwp_search_results_none]
No results found, please search again.
[/searchwp_search_results_none]
</div>
<div class="search-results-pagination">
[searchwp_search_results_pagination direction="prev" link_text="Previous" var="searchvar" engine="my_test_engine"]
[searchwp_search_results_pagination direction="next" link_text="Next" var="searchvar" engine="my_test_engine"]
</div>
view raw gistfile1.html hosted with ❤ by GitHub

You can customize the attributes as per the table above.

Changelog

1.8.2

  • [Fix] Prevent Error due to Shortcode recursion
  • [Update] Updated updater

1.8.1

  • [Fix] posts_per_page attribute not reflected when using SearchWP 4

1.8.0

  • [New] New Shortcode searchwp_search_results_paginate_links for paginated links
  • [New] New Shortcode searchwp_search_result_image for result Featured Image output
  • [New] New Shortcode searchwp_search_result_permalink for 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_results to output the total number of search results
  • [New] Adds placeholder argument to searchwp_search_form Shortcode
  • [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

Want to make your search awesome right now?

More than 30,000 sites have chosen SearchWP!

You can utilize all of the content that’s gone unrecognized by native WordPress keyword search instantly with SearchWP.

Get SearchWP for just $99

  • Committed Support
    If you need help, support is fast, friendly, and here for you
  • Streamlined Setup
    Installation and setup that’s optimized for speed
  • Great Documentation
    Helpful, clear, and usable documentation is a priority

See what SearchWP customers have to say

  • “My company is using Wordpress internally as Knowledge base system. We choose to not use menu and base everything on the search engine like Google does. SearchWP is an extremely efficient tool to find what we need quickly. I would recommend it.”

  • “We really love SearchWP. It is properly programmed, does what you expect from it and it’s very flexible. The extensions are a great addition and we often make use of them. Thanks for the great job.”

  • “SearchWP has worked well for me. At one point, I had a problem with it, and they looked into the problem and came up with a very good fix within a few days. Great service for a great product!”

[wpforms id="3080"]
[wpforms id="3080"]