In your index.php
, you should have something a bit like:
<?php if ( have_posts() ) : ?>
<!-- HTML -->
<?php while ( have_posts() ) : the_post() ?>
<!-- Post content -->
<?php endwhile ?>
<!-- HTML -->
<?php endif ?>
You can extend this code to say “if no posts and is search, display message”:
<?php if ( have_posts() ) : ?>
<!-- HTML -->
<?php while ( have_posts() ) : the_post() ?>
<!-- Post content -->
<?php endwhile ?>
<!-- HTML -->
<?php elseif ( is_search() ) : ?>
<!-- No posts and is search, show message -->
<?php endif ?>