Get images attached to posts (no problem) but need to remove the featured image
-
Hello,
I’m using the following code to get the images attached to a post and displaying them in a javascript slider:
if ( $images = get_posts(array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'numberposts' => -1, 'post_mime_type' => 'image',))) { foreach( $images as $image ) { $attachmenturl=wp_get_attachment_url($image->ID); $attachmentimage=wp_get_attachment_image_src( $image->ID, full ); $imageDescription = apply_filters( 'the_description' , $image->post_content ); $imageTitle = apply_filters( 'the_title' , $image->post_title ); if (!empty($imageDescription)) { echo '<a href="'.$imageDescription .'"><img src="' . $attachmentimage[0] . '" alt="" /></a>'; } else { echo '<img src="' . $attachmentimage[0] . '" alt="" />'; } } } else { echo "No Image"; }
This works perfectly, except that all images are retrieved from the post. I need to retrieve all images except the image I set as the featured image.
The reason being is because a customer of mine will be uploading the featured image as a different size and ratio to the other images and we can’t have the featured image in the slider.
Is there a method of being able not to retrieve a specific image when retrieving images attached to a post using the code above?
Many thanks in advance for your help.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Get images attached to posts (no problem) but need to remove the featured image’ is closed to new replies.