/* *Ajax search by redpishi.com *https://redpishi.com/wordpress-tutorials/live-ajax-search-in-wordpress/ */ add_shortcode( ‘asearch’, ‘asearch_func’ ); function asearch_func( $atts ) { $atts = shortcode_atts( array( ‘source’ => ‘page,post,product’, ‘image’ => ‘true’ ), $atts, ‘asearch’ ); static $asearch_first_call = 1; $source = $atts[“source”]; $image = $atts[“image”]; $sForam = ‘
?
Please wait..
‘; $java = ‘‘; $css = ‘‘; if ( $asearch_first_call == 1 ){ $asearch_first_call++; return “{$sForam}{$java}{$css}”; } elseif ( $asearch_first_call > 1 ) { $asearch_first_call++; return “{$sForam}”; }} add_action(‘wp_ajax_asearch’ , ‘asearch’); add_action(‘wp_ajax_nopriv_asearch’,’asearch’); function asearch(){ $the_query = new WP_Query( array( ‘posts_per_page’ => 10, ‘s’ => esc_attr( $_POST[‘s’] ), ‘post_type’ => explode(“,”, esc_attr( $_POST[‘source’] ))) ); if( $the_query->have_posts() ) : echo ‘
‘; while( $the_query->have_posts() ): $the_query->the_post(); ?>
We Are
Coming Soon
Please subscribe to newsletter to get updates from us.
Please install and activate the "
Newsletter
" plugin to show the form.