<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}
get_header();
// Get Theme Options from Database
$theme_options = pmthemes_theme_options();
echo '<div id="wrap" class="clearfix">';
    if ( $theme_options['pmthemes_display_fullw'] == false ) :
        echo '<section id="content" class="primary" role="main">';
        else:
        echo '<section id="content-full" class="primary" role="main">';
    endif;
    if (have_posts()) :
        echo '<h2 id="search-title" class="archive-title '. $theme_options['pmth_arc_align_header'] .'">';
            printf( __( 'Search Results for: %s', 'pmthemes' ), '<span>' . get_search_query() . '</span>' );
        echo '</h2>';
        if ( $theme_options['pmth_grid_col_opt'] == 'pmth-grid-coln' ) {
            $gridopt = $theme_options['pmth_grid_column'];
        } else {
            $gridopt = $theme_options['pmth_grid_width'];
        }
        echo '<div class="pmth-grid '. $gridopt .'">';
            while (have_posts()) : the_post();
                if ( 'post' == get_post_type() ) :
                    get_template_part( 'template-parts/content', $theme_options['posts_length'] );
                else :
                    get_template_part( 'template-parts/content', 'search' );
                endif;
            endwhile;
        echo '</div>';
        pmthemes_display_pagination();
    else :
        echo '<h2 id="search-title" class="archive-title '. $theme_options['pmth_arc_align_header'] .'">';
            printf( __( 'Search Results for: %s', 'pmthemes' ), '<span>' . get_search_query() . '</span>' );
        echo '</h2>';
        echo '<div class="post">';
            echo '<div class="entry">';
                echo '<p>';
                        _e('No matches. Please try again, or use the navigation menus to find what you search for.', 'pmthemes');
                echo '</p>';
                echo '<p>';
                    get_search_form();
                echo '</p>';
            echo '</div>';
        echo '</div>';
    endif;
    echo '</section>';
    if ( $theme_options['pmthemes_display_fullw'] == false ) :
        get_sidebar();
    endif;
echo '</div>';
get_footer();
?>