<div class="clearfix"></div>
<?php $arg = array('post_type' => 'slider', 'posts_per_page' => '3');
$q = new WP_Query($arg);
if ($q->have_posts()) {


?>
    <div class="slider-section">
        <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
                <?php
                $i = 0;
                while ($q->have_posts()) {
                    $q->the_post();
                    $active = ($i == 0) ? "active" : "";
                ?>
                    <li data-target="#carouselExampleIndicators" data-slide-to="<?php echo $i; ?>" class="<?php echo $active; ?>"></li>
                <?php $i++;
                } ?>
            </ol>
            <div class="carousel-inner">

            <?php
                $i = 0;
                while ($q->have_posts()) {
                    $q->the_post();
                    $active = ($i == 0) ? "active" : "";
                ?>
                    <div class="carousel-item <?php echo $active; ?>">
                        <img src="<?php echo the_post_thumbnail_url(); ?>" alt="First slide">
                        <div class="slider-text">
                            <h1><?php the_title(); ?></h1>
                            <?php the_excerpt(); ?>
                            <ul>
                                <?php $metabox_link= get_post_meta( get_the_ID(), 'link', true );?>
                                <?php $metabox_title= get_post_meta( get_the_ID(), 'text', true );?>
                                <li><a href="<?php the_permalink(); ?>" class="btn-slider yellow">ورود</a></li>
                                <li><a href="<?php echo $metabox_link ?>" class="btn-slider wigth"><?php echo $metabox_title ?> </a></li>
                            </ul>
                        </div>
                    </div>
                    <?php
                $i++; } ?>
            </div>
      

        <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
        </a>
        <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
        </a>
        </div>
    </div>
<?php }
wp_reset_postdata(); ?>
<div class="clearfix"></div>