admin管理员组文章数量:1323178
I have a Wordpress installation that I want to reinstall. However, I also have in it several uploaded files (.doc and PDFs) that are linked by external sites. They are not used in any of my own pages: I just uploaded them to my Wordpress site instead of putting them in a Dropbox or a Google Drive, and now I can't (or shouldn't) delete them.
The good thing: they are all on the same directory: /wp-content/uploads/2020/07/
, so I could just delete everything, reinstall Wordpress and then upload the files to the same directory... However, I don't like the idea of having stray files in my Wordpress installation without WP knowing about them, so I would also like to keep the DB entries that keep track of those files.
If I'm not mistaken, the attachments are kept in the wp_posts
table, so what I would have to do is:
- Dump all the
wp_posts
entries referring to the attachments. - Dump all the
wp_postmeta
entries referring to the entries inwp_posts
. - Inserting those entries by hand in the new Wordpress' tables.
Is there anything I'm missing? Any other place in the Wordpress DB where there might be information?
I have a Wordpress installation that I want to reinstall. However, I also have in it several uploaded files (.doc and PDFs) that are linked by external sites. They are not used in any of my own pages: I just uploaded them to my Wordpress site instead of putting them in a Dropbox or a Google Drive, and now I can't (or shouldn't) delete them.
The good thing: they are all on the same directory: /wp-content/uploads/2020/07/
, so I could just delete everything, reinstall Wordpress and then upload the files to the same directory... However, I don't like the idea of having stray files in my Wordpress installation without WP knowing about them, so I would also like to keep the DB entries that keep track of those files.
If I'm not mistaken, the attachments are kept in the wp_posts
table, so what I would have to do is:
- Dump all the
wp_posts
entries referring to the attachments. - Dump all the
wp_postmeta
entries referring to the entries inwp_posts
. - Inserting those entries by hand in the new Wordpress' tables.
Is there anything I'm missing? Any other place in the Wordpress DB where there might be information?
Share Improve this question asked Sep 8, 2020 at 12:05 PaulJPaulJ 1581 silver badge7 bronze badges 1- It might be simpler to just reupload them to the new site, then edit the wp_post and wp_postmeta entries to make sure they're pointing to the old 2020/07 folder. – Rup Commented Sep 8, 2020 at 12:21
2 Answers
Reset to default 1Depending on how those inbound links work, this could be simpler than you think.
If the links are direct to files in the file system, Wordpress isn't actually needed at all - just a corresponding path for a valid URL.
So let's say you install WP today, the 'earliest' folder in uploads will be 2020/09. If you setup WP as normal and simply copy in the 2020/07 folder from your previous install, the files will be accessible to external visitors as normal. WP will not overwrite that folder as the writing of files is based on upload date (by default). It can't go back in time (without a hack).
The problem comes if their links are to attachment pages, rather than the attachments themselves. In that case, I think the simplest and most manageable option is actually to setup some redirects in htaccess. Then create new attachments in your new WP install and redirect old path to new.
I agree with @t2pe. Moreover, I would consider moving these PDFs and DOCs to independent location. Just like you mentioned: a public folder in Dropbox or Google Drive would do the trick.
Then, create a directory 2020/07
in uploads
and from there, in htaccess redirect all traffic to a cloud storage.
本文标签: postsReinstall Wordpress while keeping attachments
版权声明:本文标题:posts - Reinstall Wordpress while keeping attachments 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742131336a2422173.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论