How to query images from a post to use in a slider
I am trying to pull images as attachments from a particular post (custom post),
...and I'm using the example within WordPress codex codex example to display all images as a list
...except the images in that post keep repeating about 3 or 4 times (I have a total of 7 images attached to that post). no matter what I set the numberposts to or the post_per_page, I keep getting repeated images, about 28 when I should only have the seven.
If my numberposts is 1 or my post_per_image is 1 I only get 1 image of the 7 attached to that post... what am I doing wrong?
The code I'm using is below, and an example of what's happening on my site is here my test site where i'm trying to pull images from a post to use within FlexSlider
any help is very much appreciated. _Cindy
ul class="slides"
?php if ( have_posts() ) : while ( have_posts() ) : the_post();
$args1 = array(
'post_type' = 'attachment',
'p = 107',
'numberposts' = 7,
'post_status' = 'inherit'
);
$attachments = get_posts( $args1 );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo 'li';
echo wp_get_attachment_image( $attachment-ID, 'home-slider' );
echo '/li';
}
}
endwhile; endif; ?
/ul
/div
/div
/div
/div !-- end 1080 pixels Container --
div class="grid-gradient-bg"/div
/div
!-- Slider Navigation --
div id="home-hero-nav" role=""
div class="container" !-- 1080 pixels Container --
div class="full-width columns"
ul class="slider-menu thumbnails clearfix"
?php if ( have_posts() ) : while ( have_posts() ) : the_post();
$args2 = array(
'post_type' = 'attachment',
'p = 107',
'numberposts' = 0,
'post_status' = 'inherit'
);
$attachments = get_posts( $args2 );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo 'li';
echo wp_get_attachment_image( $attachment-ID, 'home-slider-thumb' );
echo '/li';
}
}
endwhile; endif; ?
/ul