Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Last active Apr 23, 2021
Embed
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="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>
@TriOptCorp

This comment has been minimized.

Copy link

@TriOptCorp TriOptCorp commented Apr 23, 2021

Hi,

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="http://example.com/supplemental-search/" 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: https://searchwp.com/extensions/shortcodes/

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