Skip to content

Instantly share code, notes, and snippets.

Last active Apr 23, 2021
What would you like to do?
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="" 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>
<div class="no-search-results-found">
No results found, please search again.
<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"]

This comment has been minimized.

Copy link

@TriOptCorp TriOptCorp commented Apr 23, 2021


In Wordpress, this would not be an html file, but a php file, is that correct?

Also, wouldn't you need to use:

echo do_shortcode('[searchwp_search_form engine="my_test_engine" target="" var="searchvar" button_text="Find Results"]');

For example, to get this to render correctly? Please advise. Thank you.

I saw your original sample code here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment