WP Live Search uses the WP REST API endpoint available for search. It will deliver results just as fast as the REST API on YOUR server can send them back. In the end it's important to realize that the REST API is just a wrapper for WP Query, and still uses PHP to process the requests.
Check out a demo here.
However, since we're only fetching JSON results, the search insn't being performed againts admin-ajax.php, so the experience should, in theory, be lightweight and super fast.
- Activate the WP REST API plugin
- Add the shortcode
[wp_live_search]to a page or something
WP Live Search is incredibly extensive and can be used in variety of applications from small to large.
type=""- Your choices are posts or pages. Defaults to posts. You can also pass type,type to search multiple post types. For example
multi="true"- Set only if you're using multiple post types above.
placeholder=""- The text displayed in the input. Defaults to Search....
number=""- Total search result to return. Default is 20
excerpt="true"- Show the excerpt along with the title and featured image (if set)
compact="true"- Makes a tiny WP Live Search for use in header widgets and such
dropdown="true"- Display search results as a drop-down instead of pushing down the content around it
results=""- The text displayed for the results. Defaults to entries found.
results_style=""- Displays the "entries found" inside of the input area, useful for using in areas like header widgets where space is minimal.
target=""- An optional target UL parent to send the search results to. Example
Because there are so many use cases, here are a few examples along with screenshots of how you can use WP Live Search.
Here are a few advanced options that you might find useful in your project.
Disable Style Loading
define('WPLS_STYLE_DISABLED',true); to disable the CSS style from loading. Note, you will want to add back in .wpls--show and .wpls--hide, these are responsible for showing and hiding content via JS.
Template Item Override
You can override the list item by copying the function from template-underscore.php into your own plugin (without the function exists). From here you can modify the markup as you wish, but you might want to keep the same classes so that the basic functionality is retained. It's also important to note that this will not work in a themes functions.php file, pluggable functions from a plugin will only work in another plugin.