Find all shortcode occurances on posts


I need to build an array showing all occurrences in posts of a shortcode in the form of [image=xxx] where xxx is the ID of a media attachment. The site in question has multiple uses per post of this shortcode across about 50 posts.

The final result will be an array showing attachments IDs with a list of post IDs where it occurs, e.g. [[attachment_ID],[[post_id_1], [post_id_2], [post_id_3]…]] or similar.

Ideas on how to approach this would be much appreciated.

dyg 6 months 0 Answers 73 views 0

Leave an answer