<?php
/**
 * The index template file
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 *
 * @link http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage menda
 * @since menda Theme 1.0
 */

get_header(); 

$page_id           = get_option( 'page_for_posts' );
$status            = get_post_meta( $page_id, '_ebid_sidebar_status', true );
$breadcrumbs       = get_post_meta( $page_id, '_ebid_breadcrumbs_status', true );
$page_title_status = get_post_meta( $page_id, '_ebid_pagetitle_status', true );

?>
<?php if ( $breadcrumbs !== 'hide'  ): ?>
	<div class="bradscrum">
		<div class="container-fluid">
			<div class="row"><?php ebid_breadcrumbs(); ?></div>
		</div>
	</div>
<?php endif; ?>

<div class="clearfix"></div>

<div class="container-fluid">
	<div class="col-md-12">
		<div class="row">
			<div class="col-sm-12 single col-md-<?php if( $status == 'hide' ){ echo '12'; }else{ echo '9'; } ?> col-lg-<?php if( $status == 'hide' ){ echo '12'; }else{ echo '9'; } ?> col-xs-12">
				<div id="products" class="list-group p-3">
					<div class="row">
						<?php 
						
							if ( have_posts() ) : 

								if ( is_home() && ! is_front_page() && $page_title_status !== 'hide' ) : ?>
									<header>
										<h1 class="page-title"><?php single_post_title(); ?></h1>
									</header>
								
								<?php endif; 
								
								$i=1;

								// Start the loop.
								while ( have_posts() ) : the_post();

									/**
									 * Include the Post-Format-specific template for the content.
								 	 * If you want to override this in a child theme, then include a file
									 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
									 */
									get_template_part( 'blog/contents', get_post_format() );
									
									if( $i == 3 ):
										$i = 0;
										echo sprintf( '<div class="clearfix"></div>' );
									endif;
									
									$i++;
								
								// End the loop.
								endwhile;

							else :

								get_template_part( 'template-parts/content', 'none' );

							endif;
						?>
					</div>
				</div>
			</div>

			<?php if ( $status !== 'hide' ): ?>
				<div class="col-sm-12 right-shop col-md-3 col-lg-3 col-xs-12 ">
				    <div class="sidebar-bg">
			            <div class="sidebar-shop">
						
			            	<?php get_sidebar();   ?>
			            </div>    
			         	<div class="clearfix"></div>
					</div>
				</div>
			<?php endif; ?>
		</div>
	</div>

	<div class="text-center pagi"><?php post_ebid_navi_pagination(); ?></div>
</div>

<?php get_footer(); ?>