I want to retrive attached pictures to post, do one thing with first and something else with others. I've come with this code described below, but I did something funky - it's pulling additional pictures from other post. I checked, they aren't attached to this particular post. Also, is there a way to simplify this code?
Here is my page
echo '<div class="box_gallery">';
$args = array( 'post_type' => 'attachment', 'numberposts' => 1, 'order' => 'ASC', 'post_status' => null, 'post_parent' => $post->ID );
$attachments = get_posts($args);
if ($attachments) {
foreach ( $attachments as $attachment ) {
$show_big_pic = wp_get_attachment_image( $attachment->ID, 'medium' );
echo '<div class="main_pic">'.$show_big_pic.'</div>';
}
}
echo '<div class="box_for_small_pics">';
$args = array( 'post_type' => 'attachment', 'offset' => 1, 'order' => 'ASC', 'post_status' => null, 'post_parent' => $post->ID );
$attachments = get_posts($args);
if ($attachments) {
foreach ( $attachments as $attachment ) {
$show_small_pic = wp_get_attachment_image( $attachment->ID, 'thumbnail' );
echo '<div class="small_pics">'.$show_small_pic.'</div>';
}
}
echo '</div></div>';