I am trying to load an Image Slider images from a Custom Post Type image Gallery Feature. For example let say I have an Custom Post Type called banner which I can load images to it's Gallery and I have an HTML code like this:
<div class="item active">
<img src="assets/img/ban1r.jpg" alt="">
<div class="carousel-caption">
slide 1
</div>
</div>
<div class="item active">
<img src="assets/img/ban2r.jpg" alt="">
<div class="carousel-caption">
slide 1
</div>
</div>
Can you please let me know how I can use the custom WP_Query to retrive the images from the custom post and load them into slider instead of above HTML?
So far I have done something like this but it is not displaying any image!
<?php
$args = array( 'post_type' => 'banner');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$gallery = get_post_gallery_images($post);
foreach( $gallery as $image ) {
echo '<div class="item active">';
echo '<img src="' . $image . '">';
echo '</div>';
}
endwhile;
?>
Update:
The Result of var_dump($POST)
var_dump($post);
somewhere in the loop to see what we have inside post object?var_dump($gallery);
? But honestly that should work, and does when I test it.