<?php
/**
 * The template for displaying all single posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
 *
 * @package creative_business_blog
 */

get_header();
?>

	<div id="primary" class="content-area">
		<main id="main" class="site-main ">
			<div class ="row " >
			<?php if ( absint(get_theme_mod('creative_business_blog_layout','1')) == 1 ) { 
				get_template_part( 'inc/layout/layout-1' ); 
			} elseif (absint(get_theme_mod('creative_business_blog_layout','1')) == 2 ) {
				get_template_part( 'inc/layout/layout-2' ); 
			} elseif (absint(get_theme_mod('creative_business_blog_layout','1')) == 3 ) {
				get_template_part( 'inc/layout/layout-3' ); 
			
			} 
			$nextPost = get_previous_post();
			if(!empty($nextPost) && ($nextPost->ID != get_the_ID())): ?>
				<div class="left-float-post">
					<div class="media">
						<img class="mr-3" src="<?php echo esc_url(get_the_post_thumbnail_url($nextPost->ID,'creative-business-blog-155-125'));?>">
						<div class="media-body">
						<span class="post-close" id="left-float-post"><i class="fa fa-times"></i></span>
						<span class="post-arrow "  ><i class="fa fa-backward"></i></span>
						<h3 class="mt-0 mb-1"><a href="<?php echo esc_url(get_permalink($nextPost->ID));?>"><?php echo esc_html(get_post($nextPost->ID)->post_title);?></a></h3>
						<p><?php echo esc_html(get_the_date('',$nextPost->ID));?></p>
						</div>
					</div>
				</div>
			<?php 
			endif;
			$prevPost = get_next_post();
			if(!empty($prevPost) && ($prevPost->ID != get_the_ID())):
			?>
			<div class="right-float-post">
				<div class="media">
					<img class="mr-3" src="<?php echo esc_url(get_the_post_thumbnail_url($prevPost->ID,'creative-business-blog-155-125'));?>">
					<div class="media-body">
						<span class="post-close" id="right-float-post"><i class="fa fa-times"></i></span>
						<span class="post-arrow "><i class="fa fa-forward"></i></span>
						<h3 class="mt-0 mb-1"><a href="<?php echo esc_url(get_permalink($prevPost->ID));?>"><?php echo esc_html(get_post($prevPost->ID)->post_title);?></a></h3>
					<p><?php echo esc_html(get_the_date('',$prevPost->ID));?></p> 		
					</div>
				</div>
			</div>
			<?php 
			endif; ?>
			</div>
				
    	</main><!--- #main -->
	</div>
<?php get_footer();