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

get_header();
?>

		<?php
		while ( have_posts() ) :
			the_post();

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

		endwhile; // End of the loop.
		?>
        <div class="blog_prevnext">
            <?php $prev_post = get_previous_post(); ?>
            <?php if (!empty($prev_post)) : ?>
            <a class="prevpost" href="<?php echo get_page_link($prev_post->ID); ?>" title="<?php echo $prev_post->post_title ?>"><i class="fa fa-angle-left"></i> Previous Article</a>
            <?php endif; ?>
            <?php $next_post = get_next_post(); ?>
            <?php if (!empty($next_post)) : ?>
            <a class="nextpost" href="<?php echo get_page_link($next_post->ID); ?>" title="<?php echo $next_post->post_title; ?>">Next Article <i class="fa fa-angle-right"></i></a>
            <?php endif; ?>
        </div>
        <div class="blog_nextlink">
            <?php if (!empty($prev_post)) : ?>
            <div class="blog_upcoming">
                <?php $pre_date_old = $prev_post->post_date;
                $prevDate = date("M d Y", strtotime($pre_date_old)); ?>
                <span class="b_date"><?php echo $prevDate; ?></span>
                <a href="<?php echo get_page_link($prev_post->ID); ?>" class="title"><?php echo $prev_post->post_title; ?></a>
            </div>
            <?php endif; ?>
            <?php if (!empty($next_post)) : ?>
            <div class="blog_upcoming">
                <?php $next_date_old = $next_post->post_date;
                $nextDate = date("M d Y", strtotime($next_date_old)); ?>
                <span class="b_date"><?php echo $nextDate; ?></span>
                <a href="<?php echo get_page_link($next_post->ID); ?>" class="title"><?php echo $next_post->post_title; ?></a>
            </div>
            <?php endif; ?>
        </div>
        <div class="text-center">
            <?php
            if( have_rows('social_icon','option') ): ?>
                <ul class="social_list">
                    <?php while ( have_rows('social_icon','option') ) : the_row(); ?>
                        <li>
                            <?php
                            $ls_icon = get_sub_field('si_icon');
                            if( !empty($ls_icon) ): ?>
                                <img src="<?php echo $ls_icon['url']; ?>" alt="<?php echo $ls_icon['alt']; ?>" />
                            <?php endif; ?> <span><?php the_sub_field('si_title'); ?></span>
                        </li>
                    <?php endwhile; ?>
                </ul>
            <?php endif;
            wp_reset_postdata();
            ?>
        </div>
    </section>

<?php
get_footer();
