<?php
/*
 * Template Name: 最新文章
 *
 * The template for displaying all posts.
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package daohang
 */

get_header(); ?>

	<div id="primary" class="content-area clear">

		<div id="main" class="site-main clear">

			<div class="breadcrumbs clear">
				
				<h1>
					<?php
						the_title();
					?>					
				</h1>

			</div><!-- .breadcrumbs -->

			<div id="recent-content" class="content-loop">

				<?php

					$temp = $wp_query;
					$wp_query= null;
					$wp_query = new WP_Query();
					$wp_query->query('paged='.$paged);

					if ( $wp_query->have_posts() ) :

					$i = 1;

					echo "<div class=\"posts-loop\">";

					while ($wp_query->have_posts()) : $wp_query->the_post();
					
						get_template_part('template-parts/content', 'loop');

						if ( $i == get_theme_mod('content-ad-position', '1')+1 ) {
							if ( !empty(get_theme_mod('content-ad-1')) ) {
								echo '<div class="content-ad">';
								echo get_theme_mod('content-ad-1');
								echo '</div>';
							}
						}

						if ( $i == get_theme_mod('content-ad-position2', '4')+1 ) {
							if ( !empty(get_theme_mod('content-ad-2')) ) {
								echo '<div class="content-ad">';
								echo get_theme_mod('content-ad-2');
								echo '</div>';
							}
						}	

						if ( $i == get_theme_mod('content-ad-position3', '7')+1 ) {
							if ( !empty(get_theme_mod('content-ad-3')) ) {
								echo '<div class="content-ad">';
								echo get_theme_mod('content-ad-3');
								echo '</div>';
							}
						}	
					
						$i++;

					endwhile;
					
					echo "</div><!-- .post-loop -->";

					get_template_part( 'template-parts/pagination', '' ); 

					else :

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

				?>

			<?php 
				endif;
			?>

			</div><!-- #recent-content -->
			
		</div><!-- #main -->

		<?php $wp_query = null; $wp_query = $temp;?>

	</div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>
