Shortcodes
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 )hide_button — Either “true” or “false”, hides the search form submit buttonplaceholder — Form input placeholder text (Default is Search )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_results Outputs the list of search results once a search has been submitted | engine — Search engine name (Default is default )var — The search query variable name (Default is swpquery )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_link Outputs 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_excerpt Outputs the excerpt for the current search result | None |
searchwp_search_results_none Output 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_pagination Outputs pagination of search results | engine — Search engine name (Default is default )direction — Either “prev” or “next”link_text — The text to use in the linkvar — The search query variable name (Default is swpquery ) |
searchwp_search_results_paginate_links Outputs 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 Outputs Featured Image for the current result | size — Image size (Default is thumb ) |
searchwp_search_result_permalink Outputs 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_results Outputs a total number of results for the current search | engine — Search engine name (Default is default )var — The search query variable name (Default is swpquery )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.