0

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) enter image description here

6
  • Can you place var_dump($post); somewhere in the loop to see what we have inside post object? Commented Nov 1, 2013 at 9:04
  • Hi Kristian, I updated the code with var_dump($post); please take a look at the attached image
    – Behseini
    Commented Nov 1, 2013 at 16:18
  • Can some one please help me to fix this?
    – Behseini
    Commented Nov 1, 2013 at 20:00
  • Please? any solutions or hint!
    – Behseini
    Commented Nov 3, 2013 at 0:23
  • What is var_dump($gallery);? But honestly that should work, and does when I test it.
    – s_ha_dum
    Commented Nov 3, 2013 at 2:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.