<?php
/**
 * Template part for displaying posts
 *
 */

?>

<?php 
	if ( is_single() ) :?>
		<?php
			$fields = ['source_url','source','source_logo','start_date','end_date', 'location'];
			foreach ($fields as $v) {
				$$v = get_field( $v);
			}
			the_title( '<h1>', '</h1>' );
				/* translators: %s: Name of current post */?>
				<?php echo lumbini_posted_on();?>
			<article>
			<?php 
				/**
				* For events to add dates and location
				*/
			?>	
			<?php if(get_post_type()=="event"):
				get_template_part( 'template-parts/post/content', 'event-details' );
			endif;?>
			<?php if (has_post_thumbnail()):?><div class="post-list__img post-list__img--block post-list__img--big-block"><?php the_post_thumbnail( 'lumbini-featured-image' ); ?></div><?php endif;?>

				<?php 
				/**
				* For the media coverage which will add the source information and the url
				*/
				?>			
				<?php if (	$source_url || $source || $source_logo ):?>
					<div class="sep"></div>
					<div class="source">	
						<?php if($source_logo){
							echo '<img src="'.$source_logo.'" class="source-logo"/>';
						}
						if ($source_url){
						 	echo '<p class="source-content"><a href="'. $source_url .'"  target="_blank">'. get_the_title() .'</a><br>';
				       		if($source){
				        		echo '<span class="bold dim capitalize small">'.$source.'</span>';
				      		}
				      		echo '</p>';
			      		}?>
			      		
		      		</div>
		      		<div class="sep"></div>
		      	<?php endif;?>

			<?php the_content( sprintf(
				__( 'Continue reading<span class="show-for-sr"> "%s"</span>', 'lumbini' ),
				get_the_title()
			) );?></article>
	
	<?php else :?>
		<div class="post-block medium-12 column">
			<?php if(has_post_thumbnail()):?>
				<a href="<?php the_permalink(); ?>" class="post-list__img post-list__img--block post-list__img--big-block"><?php the_post_thumbnail( 'lumbini-featured-image' ); ?></a>
			<?php endif;?>
			<h2 class="post-block__title no-margin"><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h2>
			<div class="clearfix"></div>
			<?php echo lumbini_time_link();?>	
			<div class="post-block__content">
				<?php the_excerpt();?>
			</div>
			<div class="sep"></div>

		</div>



	<?php endif;?>

