Support » Fixing WordPress » Get a list of all the post associated with an attachment
4 years, 4 months ago
Is there a way to display a list of all the posts an attachment is associated with (all the posts in which you can find the image on my website).
I want to say for example ‘This image can be found in [post title A] and [post title B]
I would also like the post titles to be wrapped in an anchor with the url of the post.
This may or may not be possible? I look forward to finding out though, so that I can move on!
Each attachment will only be associated (attached) to one post. get_permalink($post->post_parent) will return the attachment’s parent Post or Page if used inside the Loop.
Is there a way of showing multiple posts (if an attachment is used in more than one post)?
No. WordPress only stores one Post/Page attachment per media file – usually the page that the file was first inserted into or the page being edited when the attachment file was uploaded. No further uses of the file are stored.
Ok – thanks for the heads up. I can now move on.