-
-
Save sarat246/280d60a037414a37415711bff8caad7b to your computer and use it in GitHub Desktop.
Customize the parent element for SearchWP Live Ajax Search results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function my_searchwp_live_search_configs( $configs ) { | |
| // override some defaults | |
| $configs['default'] = array( | |
| 'engine' => 'default', // search engine to use (if SearchWP is available) | |
| 'parent_el' => '#results-loop', // have the results show up in a custom element | |
| 'input' => array( | |
| 'delay' => 500, // wait 500ms before triggering a search | |
| 'min_chars' => 3, // wait for at least 3 characters before triggering a search | |
| ), | |
| 'results' => array( | |
| 'position' => 'bottom', // where to position the results (bottom|top) | |
| 'width' => 'auto', // whether the width should automatically match the input (auto|css) | |
| 'offset' => array( | |
| 'x' => 0, // x offset (in pixels) | |
| 'y' => 5 // y offset (in pixels) | |
| ), | |
| ), | |
| 'spinner' => array( // powered by http://fgnass.github.io/spin.js/ | |
| 'lines' => 10, // number of lines in the spinner | |
| 'length' => 8, // length of each line | |
| 'width' => 4, // line thickness | |
| 'radius' => 8, // radius of inner circle | |
| 'corners' => 1, // corner roundness (0..1) | |
| 'rotate' => 0, // rotation offset | |
| 'direction' => 1, // 1: clockwise, -1: counterclockwise | |
| 'color' => '#000', // #rgb or #rrggbb or array of colors | |
| 'speed' => 1, // rounds per second | |
| 'trail' => 60, // afterglow percentage | |
| 'shadow' => false, // whether to render a shadow | |
| 'hwaccel' => false, // whether to use hardware acceleration | |
| 'className' => 'spinner', // CSS class assigned to spinner | |
| 'zIndex' => 2000000000, // z-index of spinner | |
| 'top' => '50%', // top position (relative to parent) | |
| 'left' => '50%', // left position (relative to parent) | |
| ), | |
| ); | |
| return $configs; | |
| } | |
| add_filter( 'searchwp_live_search_configs', 'my_searchwp_live_search_configs' ); | |
| // remove default styles | |
| add_filter( 'searchwp_live_search_base_styles', '__return_false' ); | |
| function my_remove_searchwp_live_search_theme_css() { | |
| wp_dequeue_style( 'searchwp-live-search' ); | |
| } | |
| add_action( 'wp_enqueue_scripts', 'my_remove_searchwp_live_search_theme_css', 9999 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment