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

How to change ID of an attachment in wp_posts and its related tables correctly?

your query looks good and seems workning. I’ve made a test on my database and the image remained visible in the media library after the ID change. Maybe there was already other posts existing with that IDs

Related Posts:

  1. Set attached to state
  2. Get the url of the full sized attachment image using post ID?
  3. How to force regenerate thumbnails in WordPress posts?
  4. How to extract images of post and pages excluding header and logo image in wordpress?
  5. How to get custom field image url of specific size
  6. Converting a simple plugin to be placed inside of functions.php
  7. Converting Attachment to Images?
  8. Bulk Image Uploader to create new post from each image [closed]
  9. Adding Attachment Display Settings in custom media frame
  10. Redirect to another page using contact form 7? [closed]
  11. How can I automatically download all images from all imported posts, place them on my new host, and replace all the links
  12. Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
  13. Search by Attachment ID
  14. JSON API Plugin not showing Attachments id reused
  15. Link Posts to External URL
  16. What snippet do I need to type to show my ACF field show up on my theme?
  17. Is there a way to make [Table Of Content] plugin while not using revision data?
  18. Copy/paste local images not working in WordPress
  19. Help to Create a Simple Plugin to make a post
  20. Get all image in media Gallery with alt/title?
  21. How to wrap image tag into div for post only?
  22. Get value from an input field and pass into update_meta_data as $meta_value
  23. Is there any hook to change media html in post? [duplicate]
  24. How to show post attachment image
  25. Retrieve post thumbnails
  26. Get post id in Post Page within Wp-admin
  27. getting image alt text via ACF plugin in WordPress [closed]
  28. WP galleries in posts after import. How do I do it?
  29. How to select a paragraph other than the 1st to be the post’s excerpt?
  30. posts from multiple post types in one slider
  31. How to display the featured post on the category page?
  32. How can I concatenate variables to search results title? [closed]
  33. Plugin for an interactive image? [closed]
  34. Clear out old images, any advice?
  35. Flickering sidebar when scrolling page [closed]
  36. How to fix broken media library?
  37. Is there a plugin or a way in the wordpress that would let us have different versions of a post or page accessibe to users?
  38. How to accept images at multiple sizes and aspect ratios and display as standardized image size / ratio?
  39. Moving FB comments at the end of page
  40. Where Should i write the code for wordpress ajax voting?
  41. How to get images using taxonomy ( WP Media Folder)
  42. adding Adsense’s In-Article Ads between images of blog post
  43. Add “Featured Image” box in my plugin post page
  44. download button for audio file in post [closed]
  45. check uncategorized category by default
  46. Print posts category or tag as a formatted journal
  47. Large amount image data transfer
  48. how to execute some code after a post is published in WordPress [duplicate]
  49. Post status doesn’t update to ‘future’ every time?
  50. Blurry images when loading the page first time
  51. Function added to hook “new_to_publish” not executing – custom plugin
  52. Get Image Having the ID [closed]
  53. Image Galleries for website migrated from .com to .org
  54. Retrieving post meta array (attachment)
  55. Creating an admin meta box to save post as pending
  56. trigger email when post is published by someone a user follows
  57. Grab ID from post from plugin and use it to create an object
  58. Article content navigator in wordpress like mbaskool website
  59. WP::is_main_query() Not Working
  60. Overwrite add_image_size defined by theme
  61. Scrape a webpage for image and add it to post
  62. I would like to remove date display on photo preview
  63. Post deleted in trash [closed]
  64. Getting a list of the published posts
  65. How to relate 3 wordpress components with each other (Create database relationships)
  66. Change website directory safely to add a static page on startup
  67. Show related posts based of current ACF field name in a single page post (a loop within loop)
  68. How do I link an image in my plugin so it displays on WordPress?
  69. If post exists in the database – each time goes on `else`
  70. Custom Template for wordpress cpt plugin
  71. Embed PDF into wordpress
  72. Hook Scripts and Styles in WordPress
  73. Get data from wp_posts of mysql in to variables of wordpress-php script
  74. WordPress plugin: Getting posts where checkbox selected
  75. Remember the Meta Value With Radio Buttons
  76. What hook can I use to modify custom post data before it is displayed on the page?
  77. get current page number with wp_link_pages()
  78. problem with register_activation_hook in plugin
  79. How can i summerize posts or news automatically in word press site?
  80. WordPress “Add new tag” button is not working
  81. Attachments broken after giving WordPress its own directory
  82. Delete data from custom table when deleting a post
  83. How to auto strip hyperlinks & images in wordpress post
  84. how can authors to define custom pages?
  85. Plugin is creating posts twice
  86. Some images on WordPress site are suddenly gone
  87. How to get the next and previous image title from attachment or gallery?
  88. Regenerate Thumbnails Plugin successfully updated my thumbnails but image src won’t change to new image size?
  89. “After file loaded” action
  90. Add_image_size not generating correct size
  91. Is there a way to insert multiple images into a post at the same time without using a gallery?
  92. Is there a Image Gallery which will load all my posted Images like twitter’s image grid?
  93. Multiple images per post – Show random image elsewhere
  94. Edit part of a post
  95. How to write a new file when new post has been published in WordPress
  96. WordPress Stats Plugin: Display Post Views [closed]
  97. WP Editor, save content and category on frontend
  98. Replace image urls(absolute instead of relative) by using filter in single page
  99. Plugin for TinyMCE to create reference to other posts
  100. Problem with ajax plugin for refreshing posts
Categories plugins Tags attachments, images, plugins, post-meta, posts
Woocommerce change tax rate programmaticly
Email notification after registration in WordPress

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