Yazıya eklenen tüm resimleri çeken bir fonkisyon buldum. Ancak php bilgim yeterli olmadığından işin içinden çıkamadım. Şöyle ki bulduğum fonksiyonu döngü içerisine aldığımda döngü çalışmıyor. Çıktı olarak sadece 1 tane post görünüyor.
Resimleri çeken fonksiyon:
<?php while ( have_posts() ) : the_post();
$args = array(
'post_type' => 'attachment',
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
$full_image = wp_get_attachment_image_src( $attachment->ID, 'full', false, false );
list ( $full_src, $full_width, $full_height ) = $full_image;
echo '<li><a href="'.$full_src.'" rel="shadowbox[images]">';
echo wp_get_attachment_image( $attachment->ID, 'mini' );
echo '</a></li>';
}
}
endwhile; ?>Döngü fonksiyonu ile birlikte böyle kullandım:
<?php $dongu = new WP_Query("showposts=5&cat=1"); while($dongu->have_posts()) : $dongu->the_post();?>
<?php while ( have_posts() ) : the_post();
$args = array(
'post_type' => 'attachment',
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
$full_image = wp_get_attachment_image_src( $attachment->ID, 'full', false, false );
list ( $full_src, $full_width, $full_height ) = $full_image;
echo '<li><a href="'.$full_src.'" rel="shadowbox[images]">';
echo wp_get_attachment_image( $attachment->ID, 'mini' );
echo '</a></li>';
}
}
endwhile; ?>
<?php endwhile; ?>Bu döngünün çalışması için ne gibi düzenleme yapmam gerekiyor?