I'm trying to rewrite my search.php to search only for the post titles because I have a ton of posts published to my site (around 400k), which slows down the search speed to about 20s per search.
<?php get_header();
$search_term = $_GET['s'];
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$posts = new WP_Query( array(
's' => "$search_term",
'ep_integrate' => true,
'post_type' => 'post',
'posts_per_page' => 21,
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
) );
?>
<?php if ($posts->have_posts()) :
?>
<main>
<div class="container mt-5">
<h4> Results for" <?php the_search_query(); ?></h4>
<hr style="margin-top: 0;">
<div class="row clear full-img"> ...
ep_integrate
, which suggests you’re using ElasticPress. If so, you can customise what fields are searched and how they’re weighted in the plugin’s settings.