use wp_get_attachment_url in a foreach loop
-
I have about 200 posts each with 1 image attached.
At the moment each post has a custom field with the key as ‘image’ and the value as the attachment ID, i need the value to actually be the image url.
I have this sorted for all new posts, but I need to run a one off function to get the attachment url for each existing post and save it as a custom field.
I have tried running through all posts with a foreach, grabbing the attachment id, and running wp_get_attachment_url() but i cant get it to work.
Any help appreciated
- The topic ‘use wp_get_attachment_url in a foreach loop’ is closed to new replies.