1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
フォームの全角スペースを半角スペースにリアルタイムで変更。 oninput="this.value=this.value.replace(/ /g, ' ');" ここで検索最低文字列を設定しています。 'min_chars' => 3, // wait for at least 3 characters before triggering a search <?php $str = <<<EOS <span style="position: fixed; top: 70px; width: 80%;z-index: 1;" > <form method="get" action="/"> <input type="search" style="background-color: #fffacd;" name="s" data-swplive="true" oninput="this.value=this.value.replace(/ /g, ' ');" /> <input type="submit" value="検索" /> </form> </span> EOS; echo $str ?> ーーーーー そのままコピペでは動かなかったので。 https://searchwp.com/extensions/live-search/#searchwp_live_search_configs プラグインのもともとのソースをコピーして追加。 'min_chars' => 1, だけを変更 場所は searchwp-live-ajax-search\includes\class-form.php function my_searchwp_live_search_configs( $configs ) { // override some defaults // $configs['default'] = array( // 'engine' => 'default', // search engine to use (if SearchWP is available) // 'input' => array( // 'delay' => 400, // wait 500ms before triggering a search // 'min_chars' => 1, // wait for at least 3 characters before triggering a search // ), // ); $configs['default'] = array( // 'default' config 'engine' => 'default', // Search engine to use (if SearchWP is available) 'input' => array( 'delay' => 300, // Impose delay (in milliseconds) before firing a search 'min_chars' => 1, // 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 https://spin.js.org/ 'lines' => 12, // The number of lines to draw 'length' => 8, // The length of each line 'width' => 3, // The line thickness 'radius' => 8, // The radius of the inner circle 'scale' => 1, // Scales overall size of the spinner 'corners' => 1, // Corner roundness (0..1) 'color' => '#424242', // CSS color or array of colors 'fadeColor' => 'transparent', // CSS color or array of colors 'speed' => 1, // Rounds per second 'rotate' => 0, // The rotation offset 'animation' => 'searchwp-spinner-line-fade-quick', // The CSS animation name for the lines 'direction' => 1, // 1: clockwise, -1: counterclockwise 'zIndex' => 2e9, // The z-index (defaults to 2000000000) 'className' => 'spinner', // The CSS class to assign to the spinner 'top' => '50%', // Top position relative to parent 'left' => '50%', // Left position relative to parent 'shadow' => '0 0 1px transparent', // Box-shadow for the lines 'position' => 'absolute' // Element positioning ), ); return $configs; } add_filter( 'searchwp_live_search_configs', 'my_searchwp_live_search_configs' ); |