I am using the code below to get the attached images for each post in my theme for use in a slideshow. It works great in that it is able to retrieve all of the attached images, but it also includes the post thumbnail.
So my question is, is there a way to exclude just the featured_image but display the rest of the images?
PHP
function bdw_get_images($postId) {
$iPostID = $postId;
$arrImages =& get_children('post_type=attachment&post_mime_type=image&post_parent=' . $iPostID );
if($arrImages) {
$arrKeys = array_keys($arrImages);
foreach($arrImages as $oImage) {
$arrNewImages[] = $oImage;
}
for($i = 0; $i < sizeof($arrNewImages) - 1; $i++) {
for($j = 0; $j < sizeof($arrNewImages) - 1; $j++) {
if((int)$arrNewImages[$j]->menu_order > (int)$arrNewImages[$j + 1]->menu_order) {
$oTemp = $arrNewImages[$j];
$arrNewImages[$j] = $arrNewImages[$j + 1];
$arrNewImages[$j + 1] = $oTemp;
}
}
}
$arrKeys = array();
foreach($arrNewImages as $oNewImage) {
$arrKeys[] = $oNewImage->ID;
}
$iNum = $arrKeys[0];
foreach( $arrKeys as $key) {
$sImageUrl = wp_get_attachment_url($key);
$sImgString = '<img src="' . $sImageUrl . '" alt="Thumbnail Image" />';
echo $sImgString;
}
}
}
bdw_get_images($post->ID);
Get post thumbnail(if any) by get_post_thumbnail_id( $post_id ) function and check against it in the last loop.
So the last loop should look like this: