// The Loop if ($search_query->have_posts()) $results = array(); while ($search_query->have_posts()) $search_query->the_post();
// Step 1: Register REST endpoint add_action('rest_api_init', function() register_rest_route('mytheme/v1', '/search', [ 'methods' => 'GET', 'callback' => 'ajax_search_callback', 'permission_callback' => '__return_true' ]); ); wordpress search plugin ajax
If the plugin runs WP_Query on every keystroke without caching or indexing, large sites (>10k posts) will slow down. // The Loop if ($search_query->
html += '</ul>'; resultsContainer.html(html).show(); else resultsContainer.html('<p class="no-results">' + response.data + '</p>').show(); have_posts()) $results = array()
wp_reset_postdata();