<?php get_header(); ?>
<?php    
    $author_namefirst = get_post_meta( get_the_ID(), 'author_name', true );
    $source_namefirst = get_post_meta( get_the_ID(), 'source', true );
    $author_namesecond = get_post_meta( get_the_ID(), 'author_name_second', true );
    $source_namesecond = get_post_meta( get_the_ID(), 'source_second', true );
?>
<div id="full-content" class="">
    
    
    <section style="background: url('<?php echo home_url(); ?>/wp-content/uploads/2018/11/media-coverage-banner-bg.jpg')no-repeat center/cover;"  class="media-banner-bg">  
        <div class="container">
            <div class="page-title-cus"><?php  echo 'Three Longs & Three Shorts' ?></div>
        </div>
    </section>




    <div class="container posRelative">





            <div class="floatingDiv">
						<div id="stickyShare">	
						    <div class="addthis_inline_share_toolbox"></div>
						</div>
            </div>





           





        <div class="row blog-details">
            <div class="col-md-8 col-12">

                <div class="single-blog-content"> 
                     <div class="page-title-custom">
                      <h1 class="page-title-cus"><?php if(is_page(108)) { echo 'Three Longs & Three Shorts'; } else { the_title(); } ?></h1>
                 </div>
                    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
                        <?php if( !empty($author_namefirst) || !empty($source) || !empty($author_name_second) || !empty($source_second) ) : ?>
                            <div class="author-name-g">  
                               <p> <?php if(!empty($author_namefirst)) : ?>
                                <strong>Author:</strong> <?php echo get_field('author_name'); ?><br/>
                                <?php endif; ?>
                                <?php if(!empty($source_namefirst)) : ?>
                                <strong>Source:</strong> <?php echo get_field('source'); ?>
                                <?php endif; ?><br/>

                                <?php if(!empty($author_namesecond)) : ?>
                                <strong>Author:</strong> <?php echo get_field('author_name_second'); ?><br/>
                                <?php endif; ?>
                                <?php if(!empty($source_namesecond)) : ?>
                                <strong>Source:</strong> <?php echo get_field('source_second'); ?>
                                <?php endif; ?>
                                </p>
                            </div>
                        <?php endif; ?>
                        <?php the_content(); ?>
                    <?php endwhile; ?>
                    <?php endif; ?> 
                </div>
                  
                    <div class="nxt-prev-nav clearfix">  
                        <?php 
                           // print_r( get_previous_post());
                                        $prevPost = get_previous_post();
                                        $nextPost = get_next_post();
                                       
                                        
                                        $prevTitle = get_the_title( get_previous_post() );
                                        $nextTitle = get_the_title( get_next_post() );
                                        
                                       
                                        $previous_link_url = get_permalink( get_previous_post() );
                                        $next_link_url = get_permalink( get_next_post() );

                                       
                                      
                                        
                                        
                                ?>
                        <div class="row story">
                            <div class="col-lg-6 col-md-6 col-6 prev mr-auto">
								 <?php if ($prevPost) { ?>
                                    <div class="navigation-post">
                                    <p class="nav-label"><a href="<?php echo $previous_link_url ?>">Prev Post</a></p>
                                    <div class="content">
                                        <h5 class="post-title">
                                           <a href="<?php echo $previous_link_url ?>" > <?php 
                                                 echo mb_strimwidth($prevTitle, 0,80, '...'); 
                                            ?>
                                            </a>

                                       </h5>
                                        
                                        <p class="read-more"><a href="<?php echo $previous_link_url ?>" class="view-detail">Read more</a></p>
                                    </div>
                                </div>
								 <?php } ?>
                            </div>
                            <div class="col-lg-6 col-md-6 col-6 next">
								<?php if ($nextPost) { ?>
                                <div class="navigation-post">
                                    <p class="nav-label text-right"><a href="<?php echo $next_link_url ?>">Next Post</a></p>
                                    <div class="content">
                                        <h5 class="post-title">
                                             <a href="<?php echo $next_link_url ?>" ><?php 
                                                 echo mb_strimwidth( $nextTitle, 0,80, '...'); 
                                             ?>
                                        </a>
                                        </h5>
                                       
                                        <p class="read-more"><a href="<?php echo $next_link_url ?>"  class="view-detail">Read more</a></p>
                                    </div>
                                </div>
								 <?php } ?>
                            </div>
                        </div>
                    
                
                    </div>
                         
            
        </div>
         <div class="col-md-4 col-12">
            <!--recent videos-->
            <div class="sidebar-box posts-box">
                    <h5>Recent Story</h5>
                   <div class="sidbar-posts">
                    <?php
                    //$args = array( 'numberposts' => '5' );
                    //$recent_posts = wp_get_recent_posts( $args );
                   
                    //foreach( $recent_posts as $recent ){
                        ?>
                       <?php
								$the_query = new WP_Query( array(
								'post_type'=>'story',
                                'posts_per_page'=>5,
								'order'=> 'DESC',
								'paged' => get_query_var('paged') ? get_query_var('paged') : 1) 
								); 
								 while ($the_query -> have_posts()) : $the_query -> the_post(); 
							?>
                        <div class="row post-item no-gutters">
                             
                                <div class="col-12">
                                    <div class="post-info">
                                        <p class="publish-date"><span ><?php echo the_time('d M, Y'); ?></span></p>
                                        <h3><a href="<?php echo the_permalink() ?>"> <?php echo wp_trim_words( get_the_title(), 7 ); ?></a></h5>
                                        <p><?php
                                            $category = get_the_category();
                                            if($category[0]->cat_name === 'Short Read'){
                                            ?>
                                            <span class="tag short"><?php echo $category[0]->cat_name; ?></span>
                                            <?php } elseif($category[0]->cat_name === 'Long Read'){?></span>
                                            <span class="tag long"><?php echo $category[0]->cat_name; ?></span>
                                            <?php } else { 
                                                // nothing
                                             }?>
                                        </p>
                                         

                                    </div>
                                </div>
                            </div>
                        <?php //}
                    //wp_reset_query();
                ?>
                <?php endwhile; ?>	 
                </div>
                </div>
                <!--recent videos-->
                <!--contact form-->
                 <!-- <div class="sidebar-box posts-box">
                    <h5>Get in Touch</h5>
                    <div class="sidebar-form">
                    <?php //echo do_shortcode( '[contact-form-7 id="1691" title="Get In Touch without OTP"]' ); ?>
                    </div>
                </div> -->
                <!--contact form-->
         </div>
    </div>
</div>



<div class="fixed-action-btn verticale clickToggleIcon">
		<a class="btn-floating">
			<img src="<?php bloginfo('template_directory'); ?>/images/share.svg" alt="">
		</a>        
	</div>
	<!-- Pop Message HTMl-->
	 <?php include(TEMPLATEPATH.'/includes/forms/enquiry.php'); ?>
	  <!-- Pop Message End -->
<?php get_footer(); ?>