<?php
$heading     = $args['heading'];
$description = $args['description'];
$category    = $args['category'];
$show_cta    = isset($args['show-cta']) ? $args['show-cta'] : true;

$args = array(
    'post_type'           => 'industry',
    'post_status'         => 'publish',
    'ignore_sticky_posts' => 1,
    'posts_per_page'      =>-1,
    'orderby'             => 'ASC',
    'order'               => 'ASC',
    'tax_query'           => array(array(
        'taxonomy'      => 'industry_categories',
        'field'         => 'slug', //This is optional, as it defaults to 'term_id'
        'terms'         => $category ? $category : '',
        'operator'      => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'.
    ))
);

$the_query = new WP_Query( $args );
?>

<section class="section versatile-industries">
    <div class="container">
    <div class="text-cont slide-down">
        <div class="text-cont slide-down">
            <h2 class="section-title"><?php echo $heading; ?></h2>
            <p class="section-content"><?php echo $description; ?></p>
        </div>
    </div>

  <div class="owl-carousel owl-theme industries-slider">
        <?php
            if ($the_query->found_posts!=0)
                {
                
                while ( $the_query->have_posts() ) : $the_query->the_post();
                $post_id=get_the_ID();
                    $titles  = get_the_title();
                    $content = get_the_content(); 
                    $featured_image_url = get_the_post_thumbnail_url($post_id, 'full'); 
                        ?>
            <div class="item">
                <div class="img-content">
                    <img src="<?php echo $featured_image_url; ?>" alt="<?php echo $titles; ?>" class="img-fluid">
                    <h3><?php echo $titles; ?></h3>
                </div>
                <div class="text-content">
                    <h4><?php echo $titles; ?></h4>
                    <p>
                    <?php echo $content; ?>
                    </p>
                    <?php if ($show_cta) : ?>
                        <a href="<?php echo get_field('industry_link'); ?>" class="read-more-btn" aria-label="Learn more about <?php echo $titles;?>">Read more
                            <svg width="14" height="10" viewBox="0 0 14 10" fill="none" xmlns="http://www.w3.org/2000/svg">
                                <path d="M1.02273 5.36535L11.0951 5.36535L8.8822 7.72264C8.57698 8.04778 8.57698 8.53549 8.8822 8.86063C9.18742 9.18578 9.64526 9.18578 9.95048 8.86063L13.4605 5.1215C13.7658 4.79635 13.7658 4.30864 13.4605 3.9835L9.95048 0.244357C9.64526 -0.0807861 9.18743 -0.0807862 8.8822 0.244357C8.57698 0.569499 8.57698 1.05721 8.8822 1.38236L11.0951 3.73964L1.02273 3.73964C0.641201 3.73964 0.259674 4.06478 0.259673 4.55249C0.259673 5.04021 0.641201 5.36535 1.02273 5.36535Z" fill="url(#paint0_linear_1029_627)"/>
                                <defs>
                                    <linearGradient id="paint0_linear_1029_627" x1="31.2025" y1="3.02204" x2="0.259673" y2="4.55223" gradientUnits="userSpaceOnUse">
                                        <stop stop-color="#5558A6"/>
                                        <stop offset="0.5" stop-color="#4AB9EA"/>
                                        <stop offset="1" stop-color="#D7DF23"/>
                                    </linearGradient>
                                </defs>
                            </svg>
                        </a>
                    <?php endif; ?>
                </div>
            </div>
            <?php
                      
                    endwhile;
                    wp_reset_postdata();
                    wp_reset_query();
                }
                ?>
            
        </div>

    </div>
</section>