You can try to use the wp_query->set_404 and status_header in a condition if no results found.
global $wp_query;
$wp_query->set_404();
status_header(404);
You can try to use the wp_query->set_404 and status_header in a condition if no results found.
global $wp_query;
$wp_query->set_404();
status_header(404);