Attach an image to a post with code

If you look at the media library you probably notice that all attachments are attached/unattached to a post. If the attachment is attached to a certain post, actually it’s just set as a child of that post, or its post parent is that post. Since both attachments and posts are post and they are only … Continue reading “Attach an image to a post with code”

Retrieving all the image URLs from a gallery in a wordpress post

Adding a gallery to wordpress post is being much easier, but sometimes you may find it helpful if you can retrieve all the URLs of images inserted as part of the gallery in a post. Basically we’ll use get_post_gallery to get the first gallery inserted into the post, and then use wp_get_attachment_url to get the … Continue reading “Retrieving all the image URLs from a gallery in a wordpress post”