<?php
get_header();
echo '<div class="container">';
pzy_breadcrumb_enabled() && pzy_breadcrumb();
?>
    <div class="pzy-section <?php echo pzy_breadcrumb_enabled()?'':'pzy-mt-40'?>">
        <header>
            <div class="pzy-header-title">
                <?php esc_html_e('نتایج جستجوی ', 'pezeshkyar'); ?><?php echo get_search_query(); ?>
            </div>
            <div class="pzy-header-divider"></div>
            <div class="pzy_catalog_ordering">
                <i class="pzy_catalog_ordering_icon" data-feather="filter"></i>
                <span class="pzy_catalog_ordering_title"><?php esc_html_e('مرتب سازی بر اساس:', 'pezeshkyar') ?></span>
                <form method="get" id="pzy-sort-posts">
                    <input type="hidden" name="paged" value="<?php echo get_query_var('paged', '') ?>"/>
                    <select name="orderby" id="pzy-orderby" class="orderby">
                        <option value=""><?php esc_html_e('پیش فرض', "pezeshkyar") ?></option>
                        <option value="views" <?php isset($_GET['orderby']) && selected($_GET['orderby'], 'views'); ?>><?php esc_html_e('پربازدیدها', "pezeshkyar") ?></option>
                        <option value="popular" <?php isset($_GET['orderby']) && selected($_GET['orderby'], 'popular'); ?>><?php esc_html_e('محبوبیت', "pezeshkyar") ?></option>
                        <option value="new" <?php isset($_GET['orderby']) && selected($_GET['orderby'], 'new'); ?>><?php esc_html_e('جدیدترین', "pezeshkyar") ?></option>
                    </select>
                </form>
            </div>
        </header>
        <div class="pzy-section-content pzy-mt-40">
            <div class="pzy-archive">
                <?php 
                    $is_staff = get_post_type()=="pzy_staff";
                    $sidebar = $is_staff?'service':'blog';
                ?>
                <aside class="pzy-archive-sidebar">
                    <?php get_sidebar($sidebar); ?>
                </aside>
                <section class="pzy-archive-content <?php echo ($is_staff?'pzy-staffs-archive':'');?>">
                    <div class="<?php echo ($is_staff?'pzy-staffs-consultation':'pzy-blog-posts');?>">
                        <?php
                        if(have_posts()){
                            if($is_staff){
                                echo '<div class="pzy-services-loop">';
                            }
                            while (have_posts()) {
                                the_post();
    
                                get_template_part('template-parts/loop',get_post_type());
                            }
                            if($is_staff){
                                echo "</div>";

                                if (pzy_get_option('consulation_request_target')=='show_form' && function_exists('pzy_show_consultation_form'))
                                    pzy_show_consultation_form();
                            }
                        }
                        ?>
                    </div>
                    <div class="pzy-pagination-links"><?php echo paginate_links(); ?></div>
                </section>
            </div>
        </div>
    </div>

<?php
echo "</div>";
get_footer();