I’m transferring my first WordPress site between 2 machines. I transferred the htdocs folder from Machine A to Machine B, so both versions look the same, but the content from Machine A did not load to Machine B.
How do I transfer the content (posts/pages/comments etc) from Machine A to Machine B?
You will need to transfer your database too. Export it from machine A to a text file, then import that text file on machine B. Typically you would use phpmyadmin to aid this. Then you’ll chagne the base URL in the machine B database to reflect the new location. That’ll allow you to login to your admin area in wordpress and alter any other instances of the old URL.
The problem has to do with attachments. WordPress embeds the attachment url in the post, so if you insert an image in a page it will insert <img src="www.example.com/client/images/image.jpg" />. When you transfer the database over to another machine the contents of the post isn’t updated, so all your attachments point to the old domain.
I am still looking for a tidy solution to this problem.
TBH I really love WordPress, but it’s handling of attachments let’s it down badly.
For instance, the location of the attachment on disk is not stored in the database only the URL is. So if you want to do something with an attachment in a template / plugin you have to reverse engineer the location from that.
I’m going to be coming across this problem pretty soon when this site goes live so I’ll be scouring WordPress.org for plugins and stuff then.
Wordpress should use its base URL for attachments, but it doesn’t for some reason – I’m sure they have their reasons, but I agree that it’s a right pain when transferring sites with image attachments. I’ve not transferred a wordpress site recently however, I’ll have to have a look that that is still the method they use…?