

<?php
$args = array(
  'post_type'=> 'slider',
  'posts_per_page'=> '3',
);

$slider= new WP_Query($args);
if($slider->have_posts()){

?>

<div class="slider-section">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">

    <?php
     $i=0;
     while($slider->have_posts()) : $slider->the_post();
      $active = ($i==0) ? "active" : "";
      ?>

    <li data-target="#carouselExampleIndicators" data-slide-to="<?php echo $i; ?>" class="<?php echo $active; ?>"></li>

    <?php $i++; endwhile; ?>
    </ol>
  <div class="carousel-inner" role="listbox">

    <?php
     $i=0;
     while($slider->have_posts()) : $slider->the_post();
      $active= ($i==0) ? "active" : "";
      ?>
    <div class="carousel-item <?php echo $active; ?>">
      <img class="d-block img-fluid" src="<?php the_post_thumbnail_url(); ?>" alt="<?php the_title(); ?>">
      <div class="slider-text">
      	<h1><?php the_title(); ?></h1>
      	<p><?php echo get_the_excerpt(); ?></p>
      	<a href="<?php the_permalink(); ?>" class="slider-btn yellow">تماس</a>
      	<a href="#" class="slider-btn white">اطلاعات</a>
      </div>
    </div>

    <?php $i++; endwhile; ?>

    

  </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>
<?php } wp_reset_postdata() ; ?>
<div class="clearfix"></div>