• I need to download all posts (but not all settings) from one WP site to a new one. I need to import the attached images into the media library (and keep them attached).

    The WordPress importer/exporter doesn’t do this. As the new site would be going live on the same day as the old one gets retired I can’t spend a month going through the 2000+ posts and uploading the correct images to each post.

    Would anyone know the best way to do this? Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • If both sites are self-hosted, you would copy the /wp-content/ folder and the database from one to the other, update the database to recognize and use the new URL or location (depending upon what you are actually doing) and then edit wp-config as/if necessary to use that database. Nothing there should be terribly difficult, but the idea of “live on the same day as the old one gets retired” would make me suggest getting everything other than the re-pointing of the domain done well ahead of time if your are simply moving from one server to another.

    I believe the most bullet proof way to accomplish this is to simply use the built in export and import tools that can be downloaded for WordPress in the Tools section of the admin area. The export will build an XML file that you can then use to import all of your posts, pages and media into new posts and pages on the new site.

    There are many reasons why people want to do this and there are many approaches you can use. I find this method is the most straight forward for someone who is a novice at this.

    Bob

    I need to import the attached images into the media library (and keep them attached).

    The WordPress importer/exporter doesn’t do this.

    My own experience has always been the same, but maybe there actually is a way.

    Thread Starter stunley

    (@stunley)

    Thanks for the replies.

    Bob, the importer/exporter in tools doesn’t keep images attached to posts therefore it’s not useable.

    The theme I have, uses blocks made of titles and images, which are generated from attached images – the WordPress importer breaks this.

    I could import the database and FTP the files but would this rebuild the Media Library as well as keeping the images attached?

    I could import the database and FTP the files but would this rebuild the Media Library as well as keeping the images attached?

    No rebuilding or reattachment would be required at all. The database *is* your site, and then it tells WordPress where to find uploads while content from the database is being sent to browsers for display. However, you will be “moving WordPress” (database and uploads), and that will require updating the database so it can know what URL to expect coming in from browsers and to also tell WordPress to use as just mentioned.

    Here is the SQL code I use for doing that:

    UPDATE pref_options SET option_value = replace(option_value, 'https://www.olddomain.com', 'https://www.newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
    UPDATE pref_posts SET guid = replace(guid, 'https://www.olddomain.com', 'https://www.newdomain.com');
    UPDATE pref_posts SET post_content = replace(post_content, 'https://www.olddomain.com', 'https://www.newdomain.com');

    note: Edit ‘pref’ (three places above) to your own table_prefix and change ‘https://www.olddomain.com’ and ‘https://www.newdomain.com’ as required (three places each and with no trailing slashes).

    Then, you will also need to be certain your database name, user, password and table_prefix at the server are also in wp-config.php. And finally, it is at least possible you might have a plugin using “absolute server path” that will have to be uninstalled and re-installed so it can update its own awareness as to how to find WordPress, the database and/or uploads.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Correct way to download and import posts’ is closed to new replies.