<?php
$feminine_blog_options = feminine_blog_theme_options();

$sidebar_blog_category = $feminine_blog_options['sidebar_blog_category'];
$content_length = '250';
$big_post_id = $feminine_blog_options['big_post_id'];
$paged = get_query_var('page') ? absint(get_query_var('page')) : 1;

?>


<div class="mid-section-sidebar section">
	<div class="container">
		<div class="row">
             <div class="col-md-8">
             <div class="big-featured-post">
             <?php
				if ($big_post_id) {
					$args = array(
						'post_type' => 'post',
						'p'         => $big_post_id,

					);
				

				$post_query1 = new WP_Query($args);


				if ($post_query1->have_posts()): 
					while ($post_query1->have_posts()):
                        $post_query1->the_post(); 
						$image_src = wp_get_attachment_image_src(
							get_post_thumbnail_id(),
							'full'
						);
						if($image_src){
							$url = $image_src[0];
							}
						
						?>
					<div class="big-featured-post-wrap">
						<div class="wrapper"><a href="<?php echo esc_url(get_the_permalink()); ?>"><img src="<?php echo esc_url(
                                      $url
                                  ); ?>" alt="" /></a>

							<div class="data">
								<div class="content">
								<h2 class="title"><a href="<?php echo esc_url(get_the_permalink()); ?>"><?php the_title(); ?></a></h2>
								<ul class="post-meta">
                            <li class="meta-date"><a href="<?php echo esc_url(
                                feminine_blog_archive_link($post)
                            ); ?>"><time class="entry-date published" datetime="<?php echo esc_url(
												feminine_blog_archive_link($post)
											); ?>"><?php echo esc_html(the_time(get_option('date_format'))); ?></time>
																							</a></li>
																							<li class="meta-comment"><a
																								href="<?php echo esc_url(
																									get_comments_link(
																										get_the_ID()
																									)
																								); ?>"><?php printf(
												/* translators: 1: number of comments */ _nx(
													'%1$s Comment',
													'%1$s Comments',
													get_comments_number(),
													'',
													'feminine-blog'
												),
												number_format_i18n(get_comments_number())
											); ?></a></li>
								
								
								</div>
								<p><?php echo wp_kses_post(
                                        feminine_blog_get_excerpt(
                                            $post_query1->post->ID,
                                            "550"
                                        )
                                    ); ?></p>
                                     <div class="seperator">
                                  <a href="<?php echo esc_url(
                                      get_the_permalink()
                                  ); ?>" class="readmore-link"><?php esc_html_e(
    'Continue Reading',
    'feminine-blog'
); ?></a>
</div>
							</div>
						</div>
					</div>
					<?php 
				   endwhile;
				   wp_reset_postdata();
			   endif; 
				} ?>
            </div>
                <div class="two-column-posts">
                <?php


                    if ($sidebar_blog_category && 'none' != $sidebar_blog_category) {
                        $args = [
                            'post_type' => 'post',
                            'posts_per_page' => 6,
                            'post_status' => 'publish',
                            'order' => 'desc',
                            'orderby' => 'menu_order date',
                            'tax_query' => [
                                'relation' => 'AND',
                                [
                                    'taxonomy' => 'category',
                                    'field' => 'slug',
                                    'terms' => [$sidebar_blog_category],
                                ],
                            ],
                        ];
                    } else {
                        $args = [
                            'post_type' => 'post',
                            'posts_per_page' => 6,
                            'post_status' => 'publish',
                            'order' => 'desc',
                            'orderby' => 'menu_order date',
                        ];
                    }

                $recent_query = new WP_Query($args);
                if ($recent_query->have_posts()): ?>


                        <?php
                        while ($recent_query->have_posts()):

                            $recent_query->the_post();
                            global $post;
                            $post_thumbnail_id = get_post_thumbnail_id(
                                get_the_ID()
                            );
                            $image = wp_get_attachment_image_src(
                                $post_thumbnail_id,
                                'feminine-blog-blog-thumbnail-img'
                            );
                            $content = get_the_content();

                            if (!empty($image)) {
                                $image_style =
                                    "style='background-image:url(" .
                                    esc_url($image[0]) .
                                    ")'";
                            } else {
                                $image_style = '';
                            }
                            ?>
                            <div class="carousel-content-wrap">
                                <div class="posts-wrap">
                                <a href="<?php echo esc_url(get_the_permalink()); ?>"><img src="<?php echo esc_url(
                                      $image[0]
                                  ); ?>" alt="" /></a>

                                <h2><a href="<?php echo esc_url(
                                    get_the_permalink()
                                ); ?>"><?php the_title(); ?></a></h2>

							<ul class="post-meta">
                            <li class="meta-date"><a href="<?php echo esc_url(
                                feminine_blog_archive_link($post)
                            ); ?>"><time class="entry-date published" datetime="<?php echo esc_url(
    feminine_blog_archive_link($post)
); ?>"><?php echo esc_html(the_time(get_option('date_format'))); ?></time>
                                </a></li>
                            <li class="meta-comment"><a href="<?php echo esc_url(
                                get_comments_link(get_the_ID())
                            ); ?>"><?php printf(
    /* translators: 1: number of comments */ _nx(
        '%1$s Comment',
        '%1$s Comments',
        get_comments_number(),
        '',
        'feminine-blog'
    ),
    number_format_i18n(get_comments_number())
); ?></a></li>
							</ul>
                                  <figcaption>
                                    
                                    <p><?php echo wp_kses_post(
                                        feminine_blog_get_excerpt(
                                            $recent_query->post->ID,
                                            $content_length
                                        )
                                    ); ?></p>

                                  </figcaption>
                                  <div class="seperator">
                                  <a href="<?php echo esc_url(
                                      get_the_permalink()
                                  ); ?>" class="readmore-link"><?php esc_html_e(
    'Continue Reading',
    'feminine-blog'
); ?></a>
</div>
                                </div>
                            </div>
                        <?php
                        endwhile;
                        $max_posts = $recent_query->max_num_pages;
                        if ($max_posts > 1) {
                            $current_page = max(1, get_query_var('page'));
                            echo '<div class="navigation">';

                            echo paginate_links([
                                'base' => get_pagenum_link(1) . '%_%',
                                'format' => '?paged=%#%',
                                'current' => $current_page,
                                'total' => $max_posts,
                                'type' => 'list',
                                'prev_text' => esc_html__(
                                    'Previous Posts',
                                    'feminine-blog'
                                ),
                                'next_text' => esc_html__(
                                    'More Posts',
                                    'feminine-blog'
                                ),
                            ]);
                            echo '</div>';
                        }
                        wp_reset_postdata();
                        ?>
                    <?php endif;
                ?>
             </div>
             </div>

             <?php if (is_active_sidebar('home-sidebar')): ?>
                    
                    <div class="col-md-4">
                    <aside id="secondary" class="widget-area">
                        <?php dynamic_sidebar('home-sidebar'); ?>
                        </aside>
                    </div>
                    
                    <?php endif; ?>
             
        </div>
    </div>
</div>
        
