<?php
get_header();

if ( is_home() ) {
	echo '<style>.home .site-content,.blog .site-content{width:98%;margin:50px auto;max-width:1200px;}</style>';
} else {
	echo '<h1 class="ty-h-title"><i class="fa fa-file-text-o"></i>'; wp_title(''); echo'</h1>';
}
echo '

<div class="ty-offers-pages ty-blog-page">
			
<article>
		';
		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
			query_posts(array(
			'posts_per_page' => '' . empty($ty_sub4settings["ty_blogposts_homeposts_num"])? '6' : stripslashes($ty_sub4settings["ty_blogposts_homeposts_num"]) . '',
			'paged' => $paged
			)
		);
		
		if (have_posts()) {
			if (!empty($ty_sub4settings["ty_blogpagesads_7_cont"])) {echo '<div class="ty-banner728x90 tybnr72890-12"><div>' . stripslashes($ty_sub4settings["ty_blogpagesads_7_cont"]) . '</div></div>';}
			while ( have_posts() ) : the_post();
			blogallposts();
			endwhile;
			if (empty($ty_sub4settings["ty_blogposts_chk8"])) {
				if ($paged < 2) {
					if (!empty($ty_sub4settings["ty_blogpagesads_2_cont"])) {echo '<div class="ty-banner728x90 tybnr72890-1"><div>' . stripslashes($ty_sub4settings["ty_blogpagesads_2_cont"]) . '</div></div>';}
				if (!empty($ty_sub4settings["ty_blogposts_homecats1_chk"])) {
					echo '
					<div class="ty2-sidebox ty2-sidebox-homeposts">
						<div class="ty3-sb-topbrdr"></div>
						<div class="ty3-sb-title"><a href="' . get_category_link('' . stripslashes($ty_sub4settings["ty_blogposts_homecats1_num"]) . '') . '" target="_blank">' . get_the_category_by_ID('' . stripslashes($ty_sub4settings["ty_blogposts_homecats1_num"]) . '') . '</a></div>
						<div class="ty3-sb-cont">
							<ul>
								';
								$newsposts1 = new WP_Query('cat=' . stripslashes($ty_sub4settings["ty_blogposts_homecats1_num"]) . '&showposts=' . stripslashes($ty_sub4settings["ty_blogposts_homecats1_list"]) . '');
									while ($newsposts1->have_posts()) : $newsposts1->the_post();
									blogpartposts();
									endwhile;
								echo '
							</ul>
						</div>
						<div class="ty3-sb-bottbrdr"></div>
					</div>
					';	
				}
				if (!empty($ty_sub4settings["ty_blogposts_homecats2_chk"])) {
					echo '
					<div class="ty2-sidebox ty2-sidebox-homeposts">
						<div class="ty3-sb-topbrdr"></div>
						<div class="ty3-sb-title"><a href="' . get_category_link('' . stripslashes($ty_sub4settings["ty_blogposts_homecats2_num"]) . '') . '" target="_blank">' . get_the_category_by_ID('' . stripslashes($ty_sub4settings["ty_blogposts_homecats2_num"]) . '') . '</a></div>
						<div class="ty3-sb-cont">
							<ul>
								';
								$newsposts2 = new WP_Query('cat=' . stripslashes($ty_sub4settings["ty_blogposts_homecats2_num"]) . '&showposts=' . stripslashes($ty_sub4settings["ty_blogposts_homecats2_list"]) . '');
									while ($newsposts2->have_posts()) : $newsposts2->the_post();
									blogpartposts();
									endwhile;
								echo '
							</ul>
						</div>
						<div class="ty3-sb-bottbrdr"></div>
					</div>
					';	
				}
				if (!empty($ty_sub4settings["ty_blogposts_homecats3_chk"])) {
					echo '
					<div class="ty2-sidebox ty2-sidebox-homeposts">
						<div class="ty3-sb-topbrdr"></div>
						<div class="ty3-sb-title"><a href="' . get_category_link('' . stripslashes($ty_sub4settings["ty_blogposts_homecats3_num"]) . '') . '" target="_blank">' . get_the_category_by_ID('' . stripslashes($ty_sub4settings["ty_blogposts_homecats3_num"]) . '') . '</a></div>
						<div class="ty3-sb-cont">
							<ul>
								';
								$newsposts3 = new WP_Query('cat=' . stripslashes($ty_sub4settings["ty_blogposts_homecats3_num"]) . '&showposts=' . stripslashes($ty_sub4settings["ty_blogposts_homecats3_list"]) . '');
									while ($newsposts3->have_posts()) : $newsposts3->the_post();
									blogpartposts();
									endwhile;
								echo '
							</ul>
						</div>
						<div class="ty3-sb-bottbrdr"></div>
					</div>
					';	
				}
				if (!empty($ty_sub4settings["ty_blogpagesads_3_cont"])) {echo '<div class="ty-banner728x90 tybnr72890-2"><div>' . stripslashes($ty_sub4settings["ty_blogpagesads_3_cont"]) . '</div></div>';}
				if (!empty($ty_sub4settings["ty_blogposts_homecats4_chk"])) {
					echo '
					<div class="ty2-sidebox ty2-sidebox-homeposts">
						<div class="ty3-sb-topbrdr"></div>
						<div class="ty3-sb-title"><a href="' . get_category_link('' . stripslashes($ty_sub4settings["ty_blogposts_homecats4_num"]) . '') . '" target="_blank">' . get_the_category_by_ID('' . stripslashes($ty_sub4settings["ty_blogposts_homecats4_num"]) . '') . '</a></div>
						<div class="ty3-sb-cont">
							<ul>
								';
								$newsposts4 = new WP_Query('cat=' . stripslashes($ty_sub4settings["ty_blogposts_homecats4_num"]) . '&showposts=' . stripslashes($ty_sub4settings["ty_blogposts_homecats4_list"]) . '');
									while ($newsposts4->have_posts()) : $newsposts4->the_post();
									blogpartposts();
									endwhile;
								echo '
							</ul>
						</div>
						<div class="ty3-sb-bottbrdr"></div>
					</div>
					';	
				}
				if (!empty($ty_sub4settings["ty_blogposts_homecats5_chk"])) {
					echo '
					<div class="ty2-sidebox ty2-sidebox-homeposts">
						<div class="ty3-sb-topbrdr"></div>
						<div class="ty3-sb-title"><a href="' . get_category_link('' . stripslashes($ty_sub4settings["ty_blogposts_homecats5_num"]) . '') . '" target="_blank">' . get_the_category_by_ID('' . stripslashes($ty_sub4settings["ty_blogposts_homecats5_num"]) . '') . '</a></div>
						<div class="ty3-sb-cont">
							<ul>
								';
								$newsposts5 = new WP_Query('cat=' . stripslashes($ty_sub4settings["ty_blogposts_homecats5_num"]) . '&showposts=' . stripslashes($ty_sub4settings["ty_blogposts_homecats5_list"]) . '');
									while ($newsposts5->have_posts()) : $newsposts5->the_post();
									blogpartposts();
									endwhile;
								echo '
							</ul>
						</div>
						<div class="ty3-sb-bottbrdr"></div>
					</div>
					';	
				}
				if (!empty($ty_sub4settings["ty_blogposts_homecats6_chk"])) {
					echo '
					<div class="ty2-sidebox ty2-sidebox-homeposts">
						<div class="ty3-sb-topbrdr"></div>
						<div class="ty3-sb-title"><a href="' . get_category_link('' . stripslashes($ty_sub4settings["ty_blogposts_homecats6_num"]) . '') . '" target="_blank">' . get_the_category_by_ID('' . stripslashes($ty_sub4settings["ty_blogposts_homecats6_num"]) . '') . '</a></div>
						<div class="ty3-sb-cont">
							<ul>
								';
								$newsposts6 = new WP_Query('cat=' . stripslashes($ty_sub4settings["ty_blogposts_homecats6_num"]) . '&showposts=' . stripslashes($ty_sub4settings["ty_blogposts_homecats6_list"]) . '');
									while ($newsposts6->have_posts()) : $newsposts6->the_post();
									blogpartposts();
									endwhile;
								echo '
							</ul>
						</div>
						<div class="ty3-sb-bottbrdr"></div>
					</div>
					';	
				}
				
				}
			}
			if (!empty($ty_sub4settings["ty_blogpagesads_1_cont"])) {echo '<div class="ty-banner728x90 tybnr72890-3"><div>' . stripslashes($ty_sub4settings["ty_blogpagesads_1_cont"]) . '</div></div>';}
			wp_pagenavi();
		} else {
			echo '<div class="ty-noposttext"><i class="fa fa-times"></i> هنوز مطلبی ثبت نشده</div>';
		}
		echo '
</article>

</div>

';

get_sidebar();
get_footer();


?>