Tell wordpress to show a single page instead of an archive

Here is a rough filter:

add_filter(
  'template_include',
  function($template) {
    global $wp_query;
    if (1 == $wp_query->found_posts) {
      global $wp_query;
      $type = $wp_query->get('post_type') ?: false;
      $template_type = $type ? 'single-' . $type. '.php' : 'single.php';
      if ( locate_template($template_type) ) {
        return locate_template($template_type);
      } elseif ( $type && locate_template('single.php') ) {
        return locate_template('single.php');
      }
    }
    return $template;
  }
);

You will need to alter it so that it deals with custom single-{*}.php templates gracefully. (Edit by G.M.)

I may edit the code a little later but I thought I’d get you started.