Skip to content

Instantly share code, notes, and snippets.

@searchwpgists
Last active January 17, 2023 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save searchwpgists/eb1ff51275ae7ec8371b51338cdad87a to your computer and use it in GitHub Desktop.
Save searchwpgists/eb1ff51275ae7ec8371b51338cdad87a to your computer and use it in GitHub Desktop.
A sample implementation of a SearchWP search form and corresponding results loop using the Shortcodes extension
<h3>Search Form</h3>
[searchwp_search_form engine="my_test_engine" target="http://example.com/supplemental-search/" var="swpquery" button_text="Find Results"]
<div class="search-results-wrapper">
[searchwp_total_results text="Found %total% results for %query%" engine="my_test_engine" var="swpquery"]
[searchwp_search_results engine="my_test_engine" var="swpquery" posts_per_page=10]
<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="swpquery" engine="my_test_engine"]
[searchwp_search_results_pagination direction="next" link_text="Next" var="swpquery" engine="my_test_engine"]
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment