This is my search.php:

<?php if (have_posts()) : ?>
    <h2 class="pagetitle">Page Search Results</h2>
    <?php while (have_posts()) : the_post(); ?>
        <?php if ($post->post_type == 'page') : ?>
             Show Page results
        <?php endif; ?>
    <?php endwhile; ?>

    <?php rewind_posts(); ?>
    <h2 class="pagetitle">Post Search Results</h2>
    <?php while (have_posts()) : the_post(); ?>
        <?php if ($post->post_type != 'page') : ?>
             Show non-page results
        <?php endif; ?>
    <?php endwhile; ?>

<?php else : ?>
 No Results
<?php endif; ?>

The code enables search engine results under posts be separated from individuals present in pages. If no search engine results are located for either posts or pages, the written text "No Results" is displayed.

However, when answers are found for pages although not posts (and the other way around), underneath the 'Post Search Engine ResultsInch there's nothing displayed. I'd like the code tweaked to ensure that if you will find no results found under "Publish Search Engine ResultsInch but you will find results found under "Page Search Engine Results,Inch the written text "No Results" is displayed beneath the "Publish Search Engine ResultsInch header.

Thanks everybody.

Give mtss is a try, you are able to expand the array to incorporate any publish_type your internet site is using:

<?php
    foreach (array('post','page') as $pt) :
        $search_query = new WP_Query(array(
                'post_type'         => $pt,
                's'                 => $s,
                'posts_per_page'    => 10,
                'paged'             => $paged
            )
        );
    ?>
    <?php if ($pt == 'post') : ?>
        <h2 class="pagetitle">Post Search Results</h2>
    <?php else : ?>
        <h2 class="pagetitle">Page Search Results</h2>
    <?php endif; ?>
    <?php 
        if ($search_query->have_posts()) : while ($search_query->have_posts()) : $search_query->the_post();
        if ($pt == 'post') :
    ?>
        Post Results Code
    <?php else : ?>
        Page Results Code
    <?php endif; ?>
    <?php endwhile; else : ?>
        No Results
    <?php endif; ?>
<?php endforeach; ?>