My question is basically identical to this other question here, however my question is still slightly different. I basically have a custom post type called “Packages” each package can have a slideshow with its own images.
I understand the images are uploaded through the media uploader (as per the associated questions chosen answer), however is it possible to only get a list of images attached to the post that AREN’T the featured image?
My understanding is that the answer given to the other question would get all images including the featured image, does WordPress treat featured images differently in the background so I can exclude them?
Generally speaking, I would take the approach of querying for post attachments, but withhold the attachment that is the post thumbnail. WP provides a simple way of finding the post thumbnail ID with
get_post_thumbnail_id
(Codex Ref). To modify the code from the other post, I would add the following parameter to the$args
array to withhold the thumbnail attachment from being queried:The
post__not_in
parameter will “Specify post NOT to retrieve.” (Codex Ref)To put the whole thing together, the code would look like:
In order to further fine tune your queries, I would highly recommend exploring the WP_Query class (Codex Ref). It’s power is only rivaled by its ease of use.
You could basically use the code from that other question and then filter out the featured image by looking at the post thumbnail ID.
Codex:
get_post_thumbnail_id()