<?php
/**
 * Template used for single posts and other post-types
 * that don't have a specific template.
 *
 * @package Avada
 * @subpackage Templates
 */

// Do not allow directly accessing this file.
if ( ! defined( 'ABSPATH' ) ) {
	exit( 'Direct script access denied.' );
}
?>
<?php get_header(); ?>

<?php $banner_image = get_field('banner_image',10468);?>

<div class="banner-page-blog fusion-fullwidth" style="background-image:url('<?=$banner_image['url'];?>')">
    <h1 style="text-align:center;">BLOG</h1>
</div>

<div class="single-post-content">
	<div class="container">
		<div class="top-content">
			<h2><?=the_title();?></h2>
		</div>
		<div class="content">
			<?=get_field('description');?>
		</div>
		<div class="social-media-icon">
			<?=do_shortcode( '[Sassy_Social_Share]' );?>
		</div>
	</div>
</div>


<?php 
			// $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
			// var_dump(get_the_ID());

			$var_current_id = get_the_ID();

            $args = array(
                'post_type' => 'post',
                'orderby'   => 'rand',
                'post__not_in' => array($var_current_id), 
                'posts_per_page' => 2,
                // 'paged' => $paged
            );

            //query_posts( $args );

            $wp_query = new WP_Query( $args );
			
			?>
<div class="blog-list-holder">
<div class="container mt-60p">
  <?php if ( $wp_query->have_posts() ) : ?> 
	<h3 class="blog-list-title">Articles You May Like</h3>
	<?php  endif; ?>
    <div class="blog-list-row">
        <?php 
            ?> 

        <?php if ( $wp_query->have_posts() ) : ?> 

        <?php while ( $wp_query->have_posts() ) : $wp_query->the_post();

            $post       = $wp_query->post;
            $post_id    = $post->ID;
            $post_title = $post->post_title; 
			$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'single-post-thumbnail' ); 
			$position  = get_field('position', $post_id);
			$name  = get_field('name', $post_id);
			$image1  = get_field('image', $post_id);   
        ?>
<div class="item">
            <div class="featured-image" style="background-image:url('<?=$image[0];?>');">
                    <!-- <?php 
                        $post_id       = $post->ID; ?>
                        <?php if (has_post_thumbnail($post_id)){
                            $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'single-post-thumbnail' ); 
                            echo '<img class="img-full" src="'. $image[0] .'" alt="'. get_the_title() .'" />';
                            } else if ( catch_that_image() ) {
                                echo catch_that_image();
                            } else {
                                echo '<img class="img-full" src="/wp-content/uploads/2022/07/press-release-770x367px-green.webp" alt="'. get_the_title() .'" />';
                            } 
                        ?> -->
                    </div>
                <div class="card-body">
                    <div class="blog-date">
                        <p class="date-txt"><?php echo get_the_date('F j, Y'); ?></p>
                    </div>
                <h5 class="card-title"> <a href="<?php the_permalink()?>"> <?php the_title(); ?> </a> </h5>
                <p class="card-text"><?php the_field('short_description')?></p>
                <div class="bottom-content">
				<div class="imageholder">
                                        <img src="<?=$image1['url'];?>" alt="<?=$image1['url'];?>">
                                </div>
                                <div class="desc">
                                    <h4><?=$name;?></h4>
                                    <span><?= $position;?></span>
                                </div>
                            </div>
              </div>
            </div>
        
        <?php endwhile;
                    endif; ?>
                     <?php wp_reset_postdata(); ?>
        
        
       
    </div>
    
</div> 
</div>

<?php get_footer(); ?>
