Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

WordPress Attachments vs Post Meta

The WordPress “gallery” functionality partly depends on the attachment of the media to the post via the post_parent column.

Specifying IDs in your shortcode allows you to include images in your
gallery that aren’t necessarily “attached” to your post — that is to
say, not uploaded from within your post or page. This flexibility
allows you to create and embed any number of galleries containing any
number of images!

Note: If you choose to just use the “barebones” version of the
shortcode in your post or page, only images that are
“attached” to that post or page will be displayed.

http://codex.wordpress.org/Gallery_Shortcode

You can see in the source that shortcode uses get_children, which has quite a comment block in the source, and again you can see that post_parent is a key factor.

There are probably other ways to answer the questions but that is the first that comes to my mind.

Related Posts:

  1. How to set author for post AND post attachments
  2. Multi-line captions on attachments
  3. How to update the title of audio file through its attachment metadata
  4. Check whether attachment ID is associated with more than one post?
  5. How To Retrieve An Image Attachment’s Alt Text?
  6. How to manage attachment relationships for specific posts in WP 3.5+
  7. Can I add a Category Metabox to attachment?
  8. Change attachment filename
  9. How to get attachment file name not attachment URL
  10. How to trigger a refresh in the media modal
  11. Correctly delete posts with meta and attachments [duplicate]
  12. What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
  13. Get all post attachments except featured image
  14. Programmatically adding images to the media library with wp_generate_attachment_metadata randomly fails
  15. getting attachement images src and add classes
  16. How can I bulk delete media and attachments using WP-CLI?
  17. Getting a taxonomy’s thumbnail url
  18. Check if post has attachments (not image)
  19. How to cleanly delete attachment but retain original file?
  20. Changing attachment urls?
  21. Add custom class to attachment in media library grid mode
  22. Are captions stored anywhere?
  23. Trying to hide buttons from Attachment window
  24. get_the_post_thumbnail() doesn’t taking style attribute
  25. Expanding new Media Uploader in WordPress 3.5
  26. How can I UN-attach media from a post?
  27. Uploading Multiple Attachments From Front-End With A Description
  28. Validate alt text for attachments?
  29. complex restriction of items in media library
  30. Remove duplicate attachments
  31. Edit image / Delete image link
  32. How could I add button next to “edit image” button in “Attachment Details”
  33. Applying automatic link class to images embedded to posts
  34. Getting attachments by meta value
  35. How to get attachment caption (get_the_excerpt gives parent post excerpt) ?
  36. Is it possible to query specific WordPress Attachment files (.ppt & .pdf) and output them in a list?
  37. media_sideload_image file name?
  38. Get all posts (of any post type) an attachment is used in
  39. Detect if is image unattached
  40. How to single click to download image in single post
  41. delete attachment from front end
  42. Unattaching unlinked images
  43. How to get attachments for a specific post type?
  44. Give attachments an archive page
  45. custom fields for attachments?
  46. Insert Media – Attachment – Link to : Remove the “attachment page” option
  47. Show Post ID in “Find Posts or Pages” box in Media Library?
  48. URL rewrite with add_rewrite_rule and attachment_id
  49. How to add media from front-end to an existing post?
  50. Can I attach a document (eg: PDF) but have a JPEG as a thumbnail?
  51. Retrieving a custom link on an attachment
  52. Get attachment from post
  53. How can I display image metadata?
  54. How can I display custom fields value from attachment media?
  55. Delete attachments from Front end
  56. Add column for attachment file size
  57. Creating a multi-file upload form on the front end for attachments
  58. how to test for attached image
  59. Unable to upload specific .zip file type via frontend in WordPress 4.0
  60. Get attachments (get_posts) and WP 3.5 new uploader
  61. get post attachments of a particular size
  62. Change image link: wp_get_attachment_link
  63. Make individual attachments private?
  64. exposing attachment uploading to the front end — delicate
  65. Gel all image from certain post type
  66. Making images from single.php pointing to an attachment .php template
  67. Add_Filter example for wp_get_attachment_link
  68. How to get meta value in wp_attachment_metadata
  69. Change the Permalink for wordpress attachment
  70. How to upload image from front end and save in media library?
  71. Can i hide the attachments from media which I uploaded from front end?
  72. ID of images from gallery
  73. Get the attachment URL on single.php
  74. How to get list of paths (not urls) for an image
  75. Display info from custom fields in all images’ HTML
  76. wp_get_attachment_image_src always returns false
  77. Exact image sizes
  78. attachment url rewrite
  79. Get the size (size in Kb or MB) of an featured image?
  80. copy attachments to another post type and change attachment url
  81. ajax delete value from custom field array
  82. Save attachment custom fields on front end
  83. Short of raw SQL, can I query for multiple attachment metadata that have a given array key?
  84. Adding attachment file name to email link
  85. Automatically delete attachments and posts [closed]
  86. How to allow specific extensions and file size to wp_mail attachment?
  87. Adding meta data to an attachment post
  88. How to get custom field image url of specific size
  89. Get attachment file link
  90. How to grab the first two image attachments from a post?
  91. wp_insert_post featured image from library
  92. How to delete orphan attachments?
  93. the_content() behavior on attachment.php versus single.php
  94. How to count media attachments?
  95. Regenerate missing _wp_attachment_metadata
  96. How to create a CSV on the fly and send as an attachment using wp_mail?
  97. attachments with tags and get_posts
  98. Hide “Gallery Settings” and “Insert into Post” button from Attachment window
  99. Get the title and URL of the attachment parent post
  100. How can I change wordpress attachment url and protect it?
Categories attachments Tags attachments, post-meta
Second tier sidebar navigation
Get the number of rows from $wpdb->get_results not working

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress