title: Regular posts first (descending order), then custom post type (alphabetical) in WP search
body: <p>I've been cobbling together bits and pieces of various examples together but can't seem to wrap my head around this. </p>
  
  <p>I have regular blog posts (News) that I would like displayed with the most recent on top followed by a custom post type (Businesses) that I would like grouped below the News. I am using Sage and this is my first theme.</p>
  
  <p>Here is my beginner code so far:</p>
  
  <pre><code>&lt;?php get_template_part('templates/page', 'header'); ?&gt;
  
      &lt;?php if (!have_posts()) : ?&gt;
          &lt;div class="alert alert-warning"&gt;
              &lt;?php _e('Sorry, no results were found.', 'sage'); ?&gt;
          &lt;/div&gt;
          &lt;?php get_search_form(); ?&gt;
              &lt;?php endif; ?&gt;
  
                  &lt;?php if ( have_posts() ) : ?&gt;
                      &lt;?php while ( have_posts() ) : the_post(); ?&gt;
                          &lt;?php $post_type = get_post_type_object( get_post_type() ); ?&gt;
                              &lt;?php $type = get_post_type(); ?&gt;
  
                                  &lt;?php if ($type == 'post') { ?&gt;
                                      &lt;h2&gt;News Results&lt;/h2&gt;
                                      &lt;article id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt;
                                          &lt;div&gt;
                                              &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;
                                                  &lt;?php $cats=get_the_category(); ?&gt;
                                                      &lt;?php echo $cats[0]-&gt;cat_name; ?&gt;
  
                                              &lt;/a&gt;
                                          &lt;/div&gt;
                                          &lt;div&gt;
                                              &lt;h3&gt;&lt;?php the_title(); ?&gt;&lt;/h3&gt;
  
                                              &lt;div class="result-excerpt"&gt;
                                                  &lt;?php if ( has_excerpt( $post-&gt;ID ) ) {
                echo the_excerpt(); 
              } else {
                echo get_excerpt(); 
              } ?&gt;
                                              &lt;/div&gt;
  
                                          &lt;/div&gt;
                                      &lt;/article&gt;
  
                                      &lt;?php } elseif ($type == 'business') { ?&gt;
  
                                          &lt;h2&gt;Business Results&lt;/h2&gt;
                                          &lt;article &lt;?php post_class(); ?&gt;&gt;
                                              &lt;header&gt;
                                                  &lt;h2 class="entry-title"&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
                                                  &lt;?php if (get_post_type() === 'post') { get_template_part('templates/entry-meta'); } ?&gt;
                                              &lt;/header&gt;
                                              &lt;div class="entry-summary"&gt;
                                                  &lt;?php the_excerpt(); ?&gt;
                                              &lt;/div&gt;
                                              &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;
                                                  &lt;?php $cats=get_the_category(); ?&gt;
                                                      &lt;?php echo $cats[0]-&gt;cat_name; ?&gt; -
                                                          &lt;?php the_title(); ?&gt;
                                              &lt;/a&gt;
                                              &lt;h3&gt;&lt;?php echo the_sub_field('title'); ?&gt;&lt;/h3&gt;
                                              &lt;?php if( get_sub_field('content') ): ?&gt;
                                                  &lt;div class="result-excerpt"&gt;
                                                      &lt;?php echo custom_field_excerpt(); ?&gt;
                                                  &lt;/div&gt;
                                                  &lt;?php endif; ?&gt;
                                          &lt;/article&gt;
  
                                          &lt;?php } ?&gt;
  
                                              &lt;?php endwhile; ?&gt;
                                                  &lt;?php endif; ?&gt;
  </code></pre>