I am trying to Create Carousel Slider in which Images get from the wp_get_attachment_image_url function and all other alt title and caption data it works correctly.
I am stuck at carousel Indicators I want to connect Indicators with upload means when I will add a photo in Upload Indicator automatically add, as well if I delete the upload photo, the indicator reduce their number.
Please Help in this Function.
//This Loop I am using in (Uploads to this Page or Post) wp_get_attachment_url Slider Images Work Correctly But how to Auto Add Indicators with Upload.
<div id="demo" class="carousel slide" data-ride="carousel"><div class="carousel-inner" role="listbox">
<?php
$images =& get_children( array (
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
)); ?> <ul class="carousel-indicators"><!--how to set loop here--><li data-target="#demo" data-slide-to="0"></li><!--loop end--></ul> <?php if ( empty($images) ) { /* no attachments here */ } else { foreach ( $images as $attachment_id => $attachment ) { ?> /*Work Correctly*/ <div class="carousel-item" > <?php //you can use both methods Show Large small or medium images $result = wp_get_attachment_image_url($attachment_id, $size = 'medium', $icon); $results = wp_get_attachment_image_src($attachment_id, $size = 'large', $icon); /*Second Method very Simple and easy*/ $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); $image_title = $attachment->post_title; $caption = $attachment->post_excerpt; $description = $image->post_content; <img src="<?php echo $results[0]; ?>" alt="<?php echo $alt; ?>" title="<?php echo $image_title; ?>" /> </div> <?php } //foreach ?> </div> <a class="carousel-control-prev" href="#demo" data-slide="prev"> <span class="carousel-control-prev-icon"></span </a> <a class="carousel-control-next" href="#demo" data-slide="next"> <span class="carousel-control-next-icon"></span> </a> </div> <?php } //else ?>