ajax live search for post title

Posted by lipsius at 2020-04-08

You forget to call it in as searchinput, you can paste below code in functions.php Once you have done, find and open searchform.php. Now what you have to do, replace id element with above id element(searchInput) and add this code


Next to id element, so overall code will look like this

form method="get" class="td-search-form-widget" action="?php echo esc_url(home_url( '/' )); ?" div role="search" input class="td-widget-search-input" type="text" value="?php echo get_search_query(); ?" name="s" id="searchInput" onkeyup="fetchResults()" /input class="wpb_button wpb_btn-inverse btn" type="submit" id="searchsubmit" value="?php _etd('Search', TD_THEME_NAME)?" / /div /form

Make sure you do changes in the child theme. Now last step: add div id="datafeatch"/div just above of and you can see live search in your search form.

div id="datafeatch"/div div id="datafeatch"/div

You can also do this via live search plugin, an easiest way to do if don't know how to code. I hope it helps.