Answer the question
In order to leave comments, you need to log in
Why is the live ajax search plugin not working?
Good afternoon! I'm trying to make a simple live search for a WP theme using this jquery plugin andreaslagerkvist.com/projects/live-ajax-search
here is the functions.php code
<?php
//enqueue js and css files
add_action( 'wp_enqueue_scripts', 's_print_script' );
function s_print_script() {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'foot2livesearch', get_stylesheet_directory_uri().'/js/foot-2-live-search.js', '');
wp_enqueue_style( 'livesearchcss', get_stylesheet_directory_uri().'/css/live-search.scss');
}
add_shortcode('s_search_form_shortcode', 's_search_form_shortcode');
function s_search_form_shortcode(){
?>
<form method="get" action="/" id="live-search-example">
<div><input type="text" name="s" placeholder="Search"></div>
</form>
<script type="text/javascript">
LiveSearch.init(document.getElementById('live-search-example').querySelector('input[name=s]'), {url: '/?s='});
</script>
<?php
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question