Import post from non-wp site to wp site

I am setting up a new wp website for a client. Their current website is not wp. They have about 300 posts that need to be moved to the new site from the old site. I am able to do a csv import, but there is still a lot of work to do on each post. I would like to do an xml import to set a number of fields. My question is about setting up this xml data. I can use the export of a post on the new site as an example, but I don't know if there is another better way. Or if I create the xml file, what do I have to watch out for? For example, in the permalink, there is a 'p=9999' value. Do I need to set that to something so it would work?

Related to this, I also want to import pictures and match them to the imported posts. How do I do that?

  • Jude
    • DEV MAN

    Howdy @Charlotte

    Hope you are keeping well and welcome to the community !

    While I don't see an easy out of the box way for this, I think the best approach would be to create a sample 1 post XML export from your WP install and then manually copy / paste data into this file from the old XML and once ready do the migration.


  • Charlotte
    • WPMU DEV Initiate

    Ok, well doing manual copy/paste would have the potential of introducing many errors. I found a skeleton xml file which I am using and I'm writing a php program to build the full xml file. That is working.
    I still wonder how to add the images for the posts. I understand that images are stored in the wp_post table as type attachment. How do I associate the image to the new post? What field in the xml would hold that?
    I am thinking that I need to import the images first, return their ids in the db, then update the appropriate xml item record with the id. Is that the right series of steps? And what is the field in the post xml to update?
    Or can someone point me to documentation that can help me answer this question?

  • Jude
    • DEV MAN

    Hi again Charlotte

    Yes the way to do this is to add them to the appropriate folder and paste the link in the guid column and post_parent column if you want the image linked to a post.

    Looks around for docs, not able to find much in this area.

    Hope that helps.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.