AJAX Configuration
As of version 1.4, search forms can be configured to use AJAX queries instead of the traditional request method.
Enabling AJAX for your search can provide users with a more seamless experience by not requiring a full page reload to show results. AJAX configuration is set by extending the ‘form’ section of your arguments array like so:
$args [ 'form' ][ 'ajax' ] = array ( // arguments here ); |
Be aware that using an AJAX-enabled search requires a different approach to setting up your page templates. See this page for templating instructions.
Available Parameters:
- enabled
(boolean) true / false
- Context: Turns AJAX mode on or off
- Default: false
- button_text
(string)
- Context: Sets custom text for the “load more” button
- Default: “Load More Results”
- show_default_results
(boolean)
- Context: Specifies whether to show an initial list of search results on page load according to your search defaults
- Default: true
- loading_img
(string) Complete URL to the image file
- Context: Sets a custom loading graphic to be displayed while results are loading
- Default: None
- results_template
(string)
- Context: Specifies the template to use for displaying search results
- Default: Defaults to the framework’s example template located in templates/template-ajax-results.php
- Configuration
- Fields
- search
- taxonomy
- meta_key
- date
- post_type
- order
- orderby
- author
- posts_per_page
- generic
- html
- submit
- clear
- reset
- Field Parameters
- Template Setup
- Plugins