<?php
/*
Theme Designed By: Meysam Hosseinkhani
Email: Meysam98@Gmail.com
Author Website: Hosseinkhani.ir
*/
   // Exit if accessed directly
   if (!defined('ABSPATH')) {
    exit;
} ?>
<?php
                $main_cat = '';
                if (!empty($az_data['main_blog_cat'])) {
                    $main_cat = $az_data['main_blog_cat'];
                }
               $blogpost = new WP_Query(array(
                'posts_per_page' => $az_data['main_blog_count'],
                'post_type' => 'post',
                'post_status' => 'publish',
                'category__in' => $main_cat
            ));
            if ($az_data['show_mbtn'])
                {
                if (!empty($az_data['main_blog_cat']))
                    {
                    if (count($az_data['main_blog_cat']) == 1)
                        {
                        $mlink = get_category_link($az_data['main_blog_cat'][0]);
                        }
                      else
                        {
                        $mlink = get_home_url() . '/?cat=';
                        foreach($az_data['main_blog_cat'] as $cat)
                            {
                            $mlink.= $cat . ',';
                            }
                        }
                    }
                  else
                    {
                    $mlink = get_home_url() . '/?post_type=post&s=';
                    }
                }?>
    <div class="rcon">
        <div class="m-product">
                    <div class="post-title">
                        <h3><span class="<?php echo $az_data['main_blog_icon']; ?>"></span>
                            <?php echo $az_data['main_blog_title']; ?>
                        </h3>
                        <?php if ($az_data['show_mbtn']) { ?><a class="float-left morebtn" href="<?php echo $mlink; ?>">
                            <?php echo $az_data['text_more']; ?> <i class="fas fa-chevron-left"></i></a>
                        <?php } ?>
                    </div>
            <div class="owl-carousel <?php if($az_data['main_blog_play']) { echo 'auto-play'; } else {echo 'nauto-play';} ?>">
                <?php
                if($blogpost->have_posts()){ 
               while ( $blogpost->have_posts() ) : $blogpost->the_post(); ?>

                <div class="item">
                    <div class="rcol">
                        <div class="r-box r-box-view">
                            <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
                                <div class="figure">
                                    <div class="fig">
                                        <span class="fig-price"><span>
                                                <?php echo $az_data['text_more_text']; ?></span></span>
                                        <?php p_mimg() ?>
                                    </div>
                                    <div class="figcaption">
                                        <?php the_title(); ?>
                                    </div>
                                </div>
                            </a>
                        </div>
                    </div>
                </div>
                <?php endwhile;
                }
                else {echo 'لطفا ابتدا نوشته ای را اضافه نمایید.';}
                     wp_reset_postdata();
                     ?>
            </div>
        </div>
    </div>