markjaquith / feedback

Ask @markjaquith anything!
42 stars 4 forks source link

WordPress question.. #58

Closed PaulCoughlin closed 9 years ago

PaulCoughlin commented 9 years ago

Hi Mark,

With WordPress, I think one of the biggest pains, is when moving or deploying sites, and having to change references to the domain the existing site is on/site url. Seems a search/replace on the database is how it's handled usually..

But if WordPress has an actual value, stored in its database - like the site url, then why not use that value as a variable in everything internally?

Wouldn't it be good to have every reference to the site url stored internally as a simple variable, so that only 1 value has to be changed when deploying or moving sites?

I get I'm oversimplifying, but the idea seems a good one to me :-)

Thanks, Paul

markjaquith commented 9 years ago

You should really only see URLs hardcoded in post content. We are very cautious about modifying people's post content. Take something like: <a href="http://example.com/some-link/">internal link</a>. Yeah, we could change that to <a href="/some-link/">internal link</a>, but what if you wanted to export that content to a different site? Then the link would break. What if you wanted to move some content to another site, and then move the first site to a new domain? If the URLs are left as absolute in the content, it’s clear where they should point, no matter where the content ends up.

WP-CLI has a command to do search and replace, and doing a search/replace on post_content is pretty trivial.

http://wp-cli.org/commands/search-replace/

PaulCoughlin commented 9 years ago

Thanks Mark - much appreciated.. Paul

------ Original Message ------ From: "Mark Jaquith" notifications@github.com To: "markjaquith/feedback" feedback@noreply.github.com Cc: "Paul Coughlin" paul+github@paulcoughlin.com Sent: 14/03/2015 19:11:59 Subject: Re: [feedback] WordPress question.. (#58)

Closed #58.

— Reply to this email directly or view it on GitHub.