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

Media attachment date and post date

Iterate over all posts, find the attached images …

$images =& get_children( 
    array ( 
        'post_type'      => 'attachment', 
        'post_mime_type' => 'image' 
);

… and for each image use wp_update_post() to set the date from the parent post.

Related Posts:

  1. Uploading Images to Media Library via wp_handle_sideload() fails
  2. How to upload an image in the plugin’s options page
  3. Share media among different domains
  4. Media_handle_upload with custom upload folder?
  5. Organize media uploads in folders – I have a physical access to (my) server
  6. Create a User Role with permissions to only upload files to the media library?
  7. Is it possible to share WordPress media files among different domains?
  8. Randomizing Post Links Outside of Loop – No Author or Date
  9. How do you update post date (year only) in a separate custom field?
  10. Uploads folder only showing files up to the letter “P”
  11. Media Library not showing images when adding to Posts (but retrieving image info via ajax)
  12. How to Protect Uploads, if User is not Logged In?
  13. Change the default-view of Media Library in 3.5?
  14. Get All Images in Media Gallery?
  15. How to Fix HTTP Error When Uploading Images?
  16. Trigger refresh for new media manager in 3.5
  17. Physical organization of wordpress media library (Real Media Library plugin)
  18. How do I select an image from Media Library in my plugin?
  19. Media Library plugins for better file management? [closed]
  20. Add “upload media” button in meta box field
  21. Extend Media Library
  22. Upload Multiple Files With media_handle_upload
  23. WordPress 3.5: Setting custom “full URL path to files” in the Media Library?
  24. How to add subfolders in media library for better organisation?
  25. Unable to select an old date in wordpress
  26. How to display .ico files in the media library
  27. How to get date for each post?
  28. Upload images to remote server
  29. List of available events for wp.media
  30. How to delete resized (cropped) image uploads and prevent future resizing?
  31. How to show all available images in WP’s media library when using the Polylang plugin?
  32. Checking if a file is already in the Media Library
  33. Order by meta value or date?
  34. Give users a maximum upload capacity; limit the number of files a user can upload OR limit the number of files per upload
  35. Save camera info as metadata on image upload?
  36. Media upload finished hook
  37. Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
  38. Users can’t upload images on frontend if they haven’t got access to the wp backend
  39. Why my uploaded picture was loaded into /uploads/2015/02 not /uploads/2016/01?
  40. How can I batch delete all unattached images with WP-CLI or other automated process?
  41. Which filters or actions to use after a media upload and delete?
  42. Custom “Uploads” Dir: “Edit Image” in Media Library broken
  43. print_media_templates not applied in media manager plugin
  44. Media not actually deleted on disk when click “Permanent Delete”
  45. Protecting direct access to PDF and ZIP unless user logged in (without plugin)
  46. How to wp_upload_bits() to a sub-folder?
  47. WordPress 3.5 attachment_fields_to_edit and media_send_to_editor
  48. Bind event on Media gallery elements WordPress
  49. How to get attachment id as soon as it is uploaded through media uploader in jquery?
  50. Change Media Uploader default directory
  51. How to restrict images in v3.5 Media Library modal to only those from a specific post id?
  52. How to hide media uploads by other users in the Media menu?
  53. How to get the image EXIF date/time and use it for the WP post date/time
  54. image_size_names_choose filter doesn’t show
  55. Add class=”media_type” when media is inserted into editor
  56. “Add Media” only shows “Full Size” under Attachment Display Settings
  57. Where do the favicons for Media Files come from
  58. WP 3.5 media manager – how to create a working gallery frame
  59. What might cause a POST to wp-admin/async-upload.php to return JSON >and< HTML?
  60. Limit Media Library to Given Folder
  61. Get date of last update outside of loop
  62. Is it possible to trigger some JavaScript when Media Popup is opened?
  63. How to call WP3.5 Media Library manager?
  64. Disable media library tab for non admins in uploader screen
  65. Creating a metabox to upload multiple images, Ignoring The Featured Image
  66. How do I ‘rebuild’ the WordPress Media library after transfer to new host?
  67. media_sideload_image file name?
  68. How to force Media manager to overwrite files of same name?
  69. Proper way to hook wp_get_attachment_url or any other way to change that url in media library
  70. How to register images uploaded via FTP in media library?
  71. Ordering posts having multiple post-meta date fields
  72. How can I list URLs of all audio files within my media gallery?
  73. How to upload images manually to wordpress?
  74. Migrating to HTTPS only, most media library links need updating?
  75. Why are double-periods (“..”) invalid in a WordPress image filename?
  76. How can I speed up a slow loading media library?
  77. Failing to open advanced-cache.php which is breaking Media Library
  78. WordPress Custom Query to show posts from last x years
  79. Password protect some uploaded files, so only logged-in users can view them
  80. Attach Files Metabox
  81. What to do with unattached logos and header uploaded via native wordpress uploader?
  82. How to protect uploads in multisite if user is not logged in?
  83. Way to force media uploader use custom image size
  84. Filter pictures in the media library [closed]
  85. WP 3.5 media uploader API set selected item
  86. How to hide CPT files from media library programmatically
  87. Is there a way to delete images from the Media Library programatically?
  88. Why time functions show invalid time zone when using ‘c’ time format?
  89. Add file name column to media library
  90. Append button to WordPress Image Details modal
  91. Add metabox with media uploader in a custom post type [duplicate]
  92. Change URLs for static content
  93. Converting Unix timestamp to wordpress date
  94. How to display date such “x ago”
  95. Downloadable Documents
  96. uploading files to the uploads folder via ftp
  97. Add item to media library from blob or dataUrl
  98. Date, Time, and Timezones
  99. Saving Custom Field in Attachment Window in WordPress 3.5
  100. Remove the columns in media library
Categories media-library Tags date, date-time, media-library, post-meta, uploads
WP newbie: using else/if statements to show multiple headers. bonks
Upgraded to 3.3, My Widgets Disappeared

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