admin管理员组

文章数量:1122832

I have two posts in my wp_posts table where post_type='attachment' The picture below shows the records related to those in wp_postmeta table

I need to change the IDs of those files. What I am doing is:

update wp_posts 
set ID = ID + 10000 
where ID in (3143,3144); 


update wp_postmeta set post_id = post_id + 10000,
                       meta_id = meta_id + 100000
where post_id in (3143,3144); 

When I do that, I am losing the images! I don't see it under "Media" section in wp-admin. In the webpage, they are not shown either. If I go: /wp-admin/upload.php?item=13143, it also does not come up. Only when I go to the link in the "guid" field of the related record at wp_posts, I see the image.

What am I missing? What am I doing wrong?

Any advice would be appreciated.

I have two posts in my wp_posts table where post_type='attachment' The picture below shows the records related to those in wp_postmeta table

I need to change the IDs of those files. What I am doing is:

update wp_posts 
set ID = ID + 10000 
where ID in (3143,3144); 


update wp_postmeta set post_id = post_id + 10000,
                       meta_id = meta_id + 100000
where post_id in (3143,3144); 

When I do that, I am losing the images! I don't see it under "Media" section in wp-admin. In the webpage, they are not shown either. If I go: /wp-admin/upload.php?item=13143, it also does not come up. Only when I go to the link in the "guid" field of the related record at wp_posts, I see the image.

What am I missing? What am I doing wrong?

Any advice would be appreciated.

Share Improve this question asked Apr 25, 2019 at 16:49 Eray BalkanliEray Balkanli 1212 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

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

本文标签: pluginsHow to change ID of an attachment in wpposts and its related tables correctly