I am using WordPress 3.3.2.
Currently I am working on a website in a dev folder on my domain, dev.domain.com. Upon creating pages and blog posts, it just occurred to me that when I move the WP website from dev.domain.com to domain.com that all the images I have used in all my pages and posts will break.
Also some images are linked to specific pages or blog posts. Those will break as well.
I don’t know why I was under the impression that when I linked to images in the WP media manager or when I linked to specific posts, the information updated if the website URL or permalink structure changed.
Can anyone advise me on either how I should go about adding pages/blog posts/images while in my dev folder so the links won’t break when I move over OR what would be the best way to fix all the broken links once I have moved the website over to domain.com?
Thank you in advance for all your advice!
There is a helpful codex article about moving WordPress: http://codex.wordpress.org/Moving_WordPress.
Basically, you need to find/replace the DB for instances of your old domain, and swap them with your new domain.
One additional trick I’ve learned when moving WordPress between environments: since WordPress stores the domain in several places as serialized data in the DB, you need to be careful when doing a find/replace on the domain name. You can use a special script like this one to do the find/replace for you, or you can do something much simpler: use domains that are the same length for dev, staging and production.
For example, your domain scheme might look like:
This way, you CAN do a straight find/replace with a text editor, and you don’t have to worry about breaking any serialized data.
One more thing: in your theme, always reference files using relative paths, or helper functions like get_bloginfo(‘template_url’). This way, you never need to modify URLs between environments.