So i want to show the images i put in a post to automatically show up in a carousel if there is more than 1 image found. I put the bootstrap Carousel in the Single-Post.php but the get_attached_media function is only finding the Featured Image of that post. Anybody know a better way to get the images from a post and show them in a carousel?
<link rel="stylesheet" href=".4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<?php
$attimages = get_attached_media('image', $post->ID);
foreach ($attimages as $image) {
echo wp_get_attachment_url($image->ID).'<br>';
?>
<div class="carousel-item active">
<img class="d-block w-100" src="<?php echo wp_get_attachment_url($image->ID); ?>" alt="First slide">
</div>
<?php
}
?>
<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>
Thanks in advance!