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

get_header();
?>

	 <div class="about_page_section cmmngap">
      <div class="container">
	<?php while ( have_posts() ) : the_post(); ?>
	      
            <div class="title_box">
               
            <h1><?php the_title(); ?></h1>
            </div>
            
            <div class="abt_pg_cont tip_page_cont">
		<div class="tip-left">
                    <figure>
                      <?php if(has_post_thumbnail()){ ?>
                            <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'full', true );?>  		
                              <img src="<?php echo $image[0];?>" alt="" class="img-fluid">
                            <?php }else{ ?>
                              <img src="<?php bloginfo('template_url');?>/images/vasstupic1.jpg" alt="" class="img-fluid">
                            <?php }?>
                     </figure>
                     <?php if(get_field('video_code')){ ?>
                     <div class="blg-vdo">

                    <!--  <iframe id="player1" src="https://www.youtube.com/embed/"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->

                     <iframe width="100%" height="315" src="https://www.youtube.com/embed/<?php the_field('video_code'); ?>" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
                 </div>
                 <?php } ?>

                <div><?php the_content(); ?></div>
		</div>
		<div class="tip-right">
		    <div class="rltd-tip date-time">
		    <!--<h2>Related Tips</h2>-->
		    <ul class="tips-list">
			
			<li class="date"><div class="time-dt"><span>Date </span><?php echo get_the_date('M d, Y'); ?></div></li>
			<li class="date"><div class="time-dt"><span>Time </span><?php echo get_the_time('g:i A'); ?></div></li>
			<?php 
			    $terms = get_the_terms($post->ID, 'category' );
			  if ($terms && ! is_wp_error($terms)) :
			      $tslugs_arr = array();
			      foreach ($terms as $term) {
				  $tslugs_arr[] = $term->slug;
			      }
			      $terms_slug_str = join( " ", $tslugs_arr);
			  endif;
			  $terms_slug_str = strtoupper ( $terms_slug_str );
			  ?>
			<li class="date"><div class="time-dt"><span>Category </span><?php echo $terms_slug_str; ?></div></li>
			
			
		    </ul>
		    </div>
		    <div class="rltd-tip">
		    <h2>Related Posts</h2>
		    <ul class="tips-list">
			<?php 
			 /*   $terms = get_the_terms($post->ID, 'tips_language' );
			  if ($terms && ! is_wp_error($terms)) :
			      $tslugs_arr = array();
			      foreach ($terms as $term) {
				  $tslugs_arr[] = $term->slug;
			      }
			      $terms_slug_strr = join( " ", $tslugs_arr);
			  endif;
			  $terms_slug_strr = strtoupper ( $terms_slug_strr ); */
			  ?>
			<?php 
			    $args = array( 'post_type' => 'post' ,'posts_per_page'=> 5,/*'tax_query' => 				array(
				array(
					'taxonomy' => 'tips_language',
					'terms' => $terms_slug_strr,
					'field' => 'slug',
					'operator' => 'IN'
				    )
				),*/);
			    $the_query = new WP_Query( $args );
			    if ( $the_query->have_posts() ) : 
			    while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
			<li><a href="<?php echo get_the_permalink(); ?>"><?php the_title(); ?></a></li>
			<?php endwhile;endif; wp_reset_query(); ?>
			
		    </ul>
		    </div>
		    <div class="rltd-tip">
		    <h2>Categories</h2>
		    <ul class="tips-list">
			<?php 
			   // Get the taxonomy's terms
			    $terms = get_terms(
				array(
				    'taxonomy'   => 'category',
				    'hide_empty' => false,
				)
			    );
			    
			    // Check if any term exists
			    if ( ! empty( $terms ) && is_array( $terms ) ) {
				// Run a loop and print them all
				foreach ( $terms as $term ) { ?>
				    <li><a href="<?php echo esc_url( get_term_link( $term ) ) ?>">
					<?php echo $term->name; ?>
				    </a></li><?php
				}
			    } 
			   
			   ?>
			
		    </ul>
		    </div>
		    <div class="scl-share">
		    <h2>Share This Post</h2>
		    <?php echo do_shortcode('[ssba-buttons]'); ?>
		</div>
		</div>
		
            </div>
	    
	    <div class="tips-commnt">
		<?php if ( comments_open() || get_comments_number() ) {
					comments_template();
				} ?>
	    </div>
	    
	    
	    
        
        <?php endwhile; ?> 	
      </div>
  </div>

<?php
get_footer();
