Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

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:

  • dev.domain.com
  • stg.domain.com
  • www.domain.com

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.

share|improve this answer
    
Sorry for the delay in my response. Thank you for the suggestions and also the link to the script. I read the wordpress link before posting this but it wasn't really a how to and I was curious if there was a proper way to do everything while developing to make the transition easier as opposed to an existing production site being moved to another URL. I haven't marked this as an answer yet because I am waiting for the new domain to be setup for me to use it. I appreciate your assistance though :). –  Damainman Apr 26 '12 at 22:01
    
I am note sure I understand what you mean with "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"?? Should I not use that script you linked because of that issue? Not sure what you mean by serialized data –  Damainman Apr 26 '12 at 22:04
    
@Damainman The script I linked to is perfectly fine to use. The first paragraph on the linked page explains the serialization issue (and why the script is necessary). All I'm saying is, the script is completely unnecessary if you just use domains of the same length when moving between dev, staging and production. If you do that, you can just dump the DB into an SQL file, and do a straight find/replace in any text editor, without needing to run any scripts. –  MathSmath Apr 27 '12 at 16:25
    
Thanks for the help :) –  Damainman Apr 30 '12 at 2:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.