如何将来自旧的、已不复存在的 wordpress 站点的图像批量上传到新的 wordpress 站点? [英] How do I bulk upload images coming from an old, defunct wordpress site to a new wordpress site?

查看:29
本文介绍了如何将来自旧的、已不复存在的 wordpress 站点的图像批量上传到新的 wordpress 站点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况是这样的:一些朋友有一个运行wordpress的旧网站,通过一些我们不会在这里讨论的恶作剧而丢失了域名和托管帐户.我有他们网站的完整备份,包括 XML 格式的 wordpress 导出文件.

Here is the situation: some friends had an old web site with wordpress running on it, and lost the domain name and hosting account through some shenanigans we won't discuss here. I have a full backup of their site, including a wordpress export file in XML.

我可以轻松地在他们的新服务器上创建一个全新的 wordpress 安装,使用导出文件将他们的所有帖子导入数据库.

I can easily create a completely new wordpress installation on their new server, using the export file to import all their posts into the database.

问题出在这里:我无法使用导入程序通过该 XML 文件提取图像和附件,因为链接错误地指向了现在不存在的旧站点.我有图片和附件,但现在我想知道如何将它们批量上传到新数据库的媒体库并正确维护或更新指向它们的链接?

The problem is here: I can't use the importer to pull over the images and attachments using that XML file, because the links are incorrectly pointing to the now non-existant old site. I have the images and attachments, but now I'm wondering how can I bulk upload them into the new database's media library and maintain, or update, the links to them properly?

扫描 wordpress 支持站点并查看插件列表会产生太多与我想要完成的内容无关的点击.

Scanning the wordpress support site and looking through the plugins list yields far too many hits that have nothing to do with what I am trying to accomplish.

我已经尝试通过修改附件帖子的 <wp:attachment_url> 条目来修改导出 XML 文件,以告诉它从本地驱动器而不是旧主机中提取文件,但是这不工作.如果有人知道 wordpress-importer 使用的特定字段,那将是非常有帮助的,我想.

I've tried modifying the export XML file to tell it to pull files from a local drive instead of the old host, by modifying attachment posts' <wp:attachment_url> entry, but this did not work. If someone knows what particular field the wordpress-importer is using, that would be quite a help, I think.

推荐答案

这仅适用于,如您在问题中所述 - 您拥有网站的 FULL BACKUP(文件和数据库)

This will work only if , like you stated in your question - you have the FULL BACKUP of the site ( files AND database )

1 - FTP 将旧站点中的所有 original wp 文件夹结构按原样放入新服务器.

1 - FTP Put all the original wp folder structure from OLD site into NEW server as - is .

2 - 登录 phpmyadmin 并导入旧数据库.

2 - login to phpmyadmin and import the OLD database .

3 - 像这样运行 SQL :

3 - run SQL like so :

/**
To update WordPress options with the new blog location, use the following SQL command:
**/

UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';

/**
After that you will need to fix URLs of the WordPress posts and pages, which translated from post slug, and stored in database wp_posts table as guid field. The URL values in this field are stored as abolute URLs instead of relative URLs, so it needs to be changed with the following SQL query:
**/

UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');

/**
If you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. Use the following SQL commands to fix all internal links to own blog in all WordPress posts and pages:
**/

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');

稍后,为了验证,转到wp_options(或prefix_options)表并搜索home_urlblog_url选项 - 看看它们是否相应改变(这取决于数据库版本)

Later , Just to verify , go to the wp_options ( or prefix_options ) table and search for home_url and blog_url options - and see if they are accordingly change ( this depends on DB version )

如果一切正常并且操作正确 - 您现在可以登录到您的新域..

If all is ok and done correctly - you now can log in to your new domain..

顺便说一句 - 如果你在本地机器上有文件和数据库,你可以运行更改,导出和导入到已经更改的数据库..(这是我通常几乎每天都这样做的方式 - 多一点时间但是傻瓜证明)

BTW - If you have files and DB on local machine , you can run the changes, export and import to the DB already changed .. ( which is how I usually do it almost on a daily basis - a bit more time but fool proof )

如果您正确地执行了上述所有操作,并且您确实拥有了之前的 ORIGINAL 数据库和文件 - 您将在新域上拥有一个新的工作副本.

If you do all the above correctly , and you did have the ORIGINAL DB and files exactly from before - you will have a new working copy on the new domain .

基本上,如果您正确执行此操作,则无需导入"任何图像.您将为整个站点执行一个简单的域迁移,包括插件、内容、图像、设置、主题以及其他……

Basically, if you do that correctly , there is no need to "import" any images . you will be performing a simple move of domain for the whole site, including plugins, content, images, settings, themes and what not ..

关于升级/版本的注意事项:当我编写原始"wp 文件夹结构时,我的意思就是这样.即使它是旧的 wp 版本和旧的插件/主题 - 首先执行上述步骤,然后才运行升级.除非您知道旧版本与 db 兼容,否则不要放置新的 wp 版本...

Note on upgrades / version: when I wrote "original" wp folder structure I meant just that . even if it an old wp version and old plugins / themes - first do those steps above , and only then run an upgrade . Do not put a new wp version unless you know the old one is db compatible ...

这篇关于如何将来自旧的、已不复存在的 wordpress 站点的图像批量上传到新的 wordpress 站点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆