<?php
/**
 * The main template file
 *
 * @package Krown
 * @subpackage Krown
 * @since Krown 1.0
 */
?>
<?php get_template_part( 'single', 'header' ); ?>
<?php get_template_part( 'top', 'menu' );?>

<!-- Single Page Layout 3 -->
<?php
    global $tlazya_krwn;
    switch($tlazya_krwn['blog_layout']) {
    case "3":
?>   
<!-- #blog -->
<section id="blog" class="section">
	<?php
	if (is_front_page()) {
	?>
	
	<div class="page-title">
		<h2><?php printf(__('Welcome to ', 'krwn')); ?><?php bloginfo('name'); ?></h2>
	</div>
	
	<?php } else { ?>
	
	<div class="page-title">
	<h2>
		<?php 
			global $tlazya_krwn; 
			if ( isset( $tlazya_krwn['blog_title'])  && $tlazya_krwn['blog_title'] != ''  ) {
		?>
		<?php
			global $tlazya_krwn;
			echo esc_html($tlazya_krwn['blog_title']);
		?>
		<?php 
			}
			else 
			{
		?>
		<?php bloginfo('name'); ?>'s Blog
		<?php
			}
		?>
		
	<h2>
	</div>
	<?php } ?>
	
	<div class="container">
		<div class="content-blog">
			<?php
				$ppp = get_option('posts_per_page', FALSE);
				$posts = array(
					'post_type'         => array('post'),
					'posts_per_page'    => $ppp,
					'post_status'       => array('publish'),
					'orderby'           => 'date',
					'order'             => 'DESC',
					'paged'             => get_query_var('paged') ? get_query_var('paged') : '1' 
				);
				query_posts($posts);
				if(have_posts())
				{
				while ( have_posts() ) : the_post();
			?>
			<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
				<div class="blog-item">
					<div class="blog-title">
						<a href="<?php the_permalink();?>">
							<h2><?php echo get_the_title();?></h2>
						</a>
					</div>
					<p class="blog-descript">
						<?php echo wp_trim_words( get_the_content(), $num_words = 14, $more = '');  ?>
					</p>
					<div class="blog-info">
						posted by <?php echo get_the_author();?> on <?php echo esc_attr(get_the_time('F')); ?> <?php echo esc_attr(get_the_time('j')); ?>, <?php echo esc_attr(get_the_time('Y')); ?> in <?php the_category(' '); ?> / <?php echo get_comments_number(); ?> comments
					</div>
				</div>
			</div>
			<?php endwhile;?>
			<div class="pagination full-width">
				<?php 
					if (function_exists("pagination")) {
						pagination($wp_query->max_num_pages);
					} 
				?>
			</div>
			<?php
				}
				else
				{
					get_template_part('content', 'none');
				}
				wp_reset_query();
			?>
		</div>
	</div>
</section>
<!-- #blog -->

<!-- ./Single Page Layout 3 -->

<!-- Single Page Layout 2 -->
<?php break; case "2": ?>

<!-- #blog -->
<section id="blog" class="section">
	
	<?php
	if (is_front_page()) {
	?>
	
	<div class="page-title">
		<h2><?php printf(__('Welcome to ', 'krwn')); ?><?php bloginfo('name'); ?></h2>
	</div>
	
	<?php } else { ?>
	
	<div class="page-title">
	<h2>
		<?php 
			global $tlazya_krwn; 
			if ( isset( $tlazya_krwn['blog_title'])  && $tlazya_krwn['blog_title'] != ''  ) {
		?>
		<?php
			global $tlazya_krwn;
			echo esc_html($tlazya_krwn['blog_title']);
		?>
		<?php 
			}
			else 
			{
		?>
		<?php bloginfo('name'); ?>'s Blog
		<?php
			}
		?>
		
	</h2>
	</div>
	<?php } ?>
	
	<div class="container">
		<div class="row">
			<div class="col-md-3">
				<!-- sidebar -->
				<div class="sidebar">
					<?php dynamic_sidebar('main-sidebar'); ?>
				</div>
				<!-- / .sidebar -->
			</div>
			<div class="col-md-9">
				<div class="content-blog">
					<?php
						$ppp = get_option('posts_per_page', FALSE);
						$posts = array(
							'post_type'         => array('post'),
							'posts_per_page'    => $ppp,
							'post_status'       => array('publish'),
							'orderby'           => 'date',
							'order'             => 'DESC',
							'paged'             => get_query_var('paged') ? get_query_var('paged') : '1' 
						);
						query_posts($posts);
						if(have_posts())
						{
						while ( have_posts() ) : the_post();
					?>
					<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
						<div class="blog-item">
							<div class="blog-title">
								<a href="<?php the_permalink();?>">
									<h2><?php echo get_the_title();?></h2>
								</a>
							</div>
							<p class="blog-descript">
								<?php  echo  wp_trim_words( get_the_content(), $num_words = 14, $more = '');  ?>
							</p>
							<div class="blog-info">
								posted by <?php echo get_the_author();?> on <?php echo esc_attr(get_the_time('F')); ?> <?php echo esc_attr(get_the_time('j')); ?>, <?php echo esc_attr(get_the_time('Y')); ?> in <?php the_category(' '); ?> / <?php echo get_comments_number(); ?> comments
							</div>
						</div>
					</div>
					<?php endwhile;?>
					<div class="pagination full-width">
						<?php 
							if (function_exists("pagination")) {
								pagination($wp_query->max_num_pages);
							} 
						?>
					</div>
					<?php
						}
						else
						{
							get_template_part('content', 'none');
						}
						wp_reset_query();
					?>
				</div>
			</div>
		</div>
	</div>
</section>
<!-- #blog -->

<!-- ./Single Page Layout 2 -->

<!-- Single Page Layout 1 -->
<?php break; case "1": ?> 

<!-- #blog -->
<section id="blog" class="section">
	
	<?php
	if (is_front_page()) {
	?>
	
	<div class="page-title">
		<h2><?php printf(__('Welcome to ', 'krwn')); ?><?php bloginfo('name'); ?></h2>
	</div>
	
	<?php } else { ?>
	
	<div class="page-title">
	<h2>
		<?php 
			global $tlazya_krwn; 
			if ( isset( $tlazya_krwn['blog_title'])  && $tlazya_krwn['blog_title'] != ''  ) {
		?>
		<?php
			global $tlazya_krwn;
			echo esc_html($tlazya_krwn['blog_title']);
		?>
		<?php 
			}
			else 
			{
		?>
		<?php bloginfo('name'); ?>'s Blog
		<?php
			}
		?>
		
	<h2>
	</div>
	<?php } ?>
	
	<div class="container">
		<div class="row">
			<div class="col-md-9">
				<div class="content-blog">
					<?php
						$ppp = get_option('posts_per_page', FALSE);
						$posts = array(
							'post_type'         => array('post'),
							'posts_per_page'    => $ppp,
							'post_status'       => array('publish'),
							'orderby'           => 'date',
							'order'             => 'DESC',
							'paged'             => get_query_var('paged') ? get_query_var('paged') : '1' 
						);
						query_posts($posts);
						if(have_posts())
						{
						while ( have_posts() ) : the_post();
					?>
					<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
						<div class="blog-item">
							<div class="blog-title">
								<a href="<?php the_permalink();?>">
									<h2><?php echo get_the_title();?></h2>
								</a>
							</div>
							<p class="blog-descript">
								<?php  echo  wp_trim_words( get_the_content(), $num_words = 14, $more = '');  ?>
							</p>
							<div class="blog-info">
								posted by <?php echo get_the_author();?> on <?php echo esc_attr(get_the_time('F')); ?> <?php echo esc_attr(get_the_time('j')); ?>, <?php echo esc_attr(get_the_time('Y')); ?> in <?php the_category(' '); ?> / <?php echo get_comments_number(); ?> comments
							</div>
						</div>
					</div>
					<?php endwhile;?>
					<div class="pagination full-width">
						<?php 
							if (function_exists("pagination")) {
								pagination($wp_query->max_num_pages);
							} 
						?>
					</div>
					<?php
						}
						else
						{
							get_template_part('content', 'none');
						}
						wp_reset_query();
					?>
				</div>
			</div>
			<div class="col-md-3">
				<!-- sidebar -->
				<div class="sidebar">
					<?php dynamic_sidebar('main-sidebar'); ?>
				</div>
				<!-- / .sidebar -->
			</div>
		</div>
	</div>
</section>
<!-- #blog -->
<div class="own_navigation">
	<div class="alignleft"><?php posts_nav_link( '', '', '&laquo; Previous Entries' ); ?></div>
	<div class="alignright"><?php posts_nav_link( '', 'Next Entries &raquo;', '' ); ?></div>
</div>
<!-- ./Single Page Layout 1 -->

<!-- Single Page Layout Default -->
<?php break; default: ?> 

<!-- #blog -->
<section id="blog" class="section">
	
	<?php
	if (is_front_page()) {
	?>
	
	<div class="page-title">
		<h2><?php printf(__('Welcome to ', 'krwn')); ?><?php bloginfo('name'); ?></h2>
	</div>
	
	<?php } else { ?>
	
	<div class="page-title">
	<h2>
		<?php 
			global $tlazya_krwn; 
			if ( isset( $tlazya_krwn['blog_title'])  && $tlazya_krwn['blog_title'] != ''  ) {
		?>
		<?php
			global $tlazya_krwn;
			echo esc_html($tlazya_krwn['blog_title']);
		?>
		<?php 
			}
			else 
			{
		?>
		<?php bloginfo('name'); ?>'s Blog
		<?php
			}
		?>
		
	<h2>
	</div>
	<?php } ?>
	
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<div class="content-blog">
					<?php
						$ppp = get_option('posts_per_page', FALSE);
						$posts = array(
							'post_type'         => array('post'),
							'posts_per_page'    => $ppp,
							'post_status'       => array('publish'),
							'orderby'           => 'date',
							'order'             => 'DESC',
							'paged'             => get_query_var('paged') ? get_query_var('paged') : '1' 
						);
						query_posts($posts);
						if(have_posts())
						{
						while ( have_posts() ) : the_post();
					?>
					<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
						<div class="blog-item">
							<div class="blog-title">
								<a href="<?php the_permalink();?>">
									<h2><?php echo get_the_title();?></h2>
								</a>
							</div>
							<p class="blog-descript">
								<?php  echo  wp_trim_words( get_the_content(), $num_words = 14, $more = '');  ?>
							</p>
							<div class="blog-info">
								posted by <?php echo get_the_author();?> on <?php echo esc_attr(get_the_time('F')); ?> <?php echo esc_attr(get_the_time('j')); ?>, <?php echo esc_attr(get_the_time('Y')); ?> in <?php the_category(' '); ?> / <?php echo get_comments_number(); ?> comments
							</div>
						</div>
					</div>
					<?php endwhile;?>
					<div class="pagination full-width">
						<?php 
							if (function_exists("pagination")) {
								pagination($wp_query->max_num_pages);
							}
						?>
					</div>
					<?php
						}
						else
						{
							get_template_part('content', 'none');
						}
						wp_reset_query();
					?>
				</div>
			</div>
		</div>
	</div>
</section>
<link rel="canonical" href="http://www.20script.ir" />
<!-- #blog -->

<?php } ?>


<?php
get_footer();