0

I have a wordpress website which I want to change, and it will takes me some months. My idea is create a subfolder in the root directory where I can set the a clone of my website to make some changes over it and at the same time keep the old website alive.

So if my website is:

mysite.com

My developing clone will be:

mysite.com/dev

The website is about news, so it has several posts which I want to keep. But I do not want to keep the media and plugins, so /wp-content/plugins and /wp-content/uploads will be empty.

I think that I have to use the same database to both sites because I want to keep the pasts posts and the posts that will be post along the developing time from the original website. So when I will finish the new website I just copy the files inside dev directory to the root directory.

So my question is, can I use the same database in two Wordpress sites where one of this is a developing clone?. A developing clone which I just want to keep the info but not the styles or media, and if I post a new post in the original site it will appear in the dev site too.

1

I'd recommend against using the same database for both. Primarily because the permalink structure would really only work for one, but also because it's very likely you'd make a change in the dev site that adversely affects your production site. If you decided to attempt something like this, all your media would still be tied to it because media is added to your database the same way posts and pages are, but instead are called attachments.

I'd look into WP Migrate DB to be able to pull in your site (or just your posts). However, you could simply import your old posts into a fresh install of Wordpress and go from there.

Good luck!

  • Hi, I like you answer, I think that importing the DB will add the posts, comments, categories...and it seems really simple. Thanks for you answer and for your time. – dperezac Dec 2 '16 at 0:22
0

you could use the same database, but just change the prefix. This would of course require you to copy the entire database (all tables) with prefix change into the same database.

I don't suggest that though. It would be easier (and safer so you don't mess with production) to download a copy of the database sql and upload this into a new database all together. This keeps files separate as well if you make any changes as part of the update. Then there is less chance of messing up production, plus when you're ready to go live you keep dev and live separate. These are all good things.

Here's what I would do:

create a subdomain for your site. if your site is www.example.com. make it dev.example.com

Copy your entire www directory into the subdomain directory that you created when you created the subdomain. (www/dev for example)

Now create a new database (you can use the same user so pw will stay the same).

in your dev directory in wp-config.php change the line for your dbname to the new database you just created. If you gave the same user permissions on this database you won't have to change dbuser or dbpw.

Make sure you've copied the database content from one database to the next. Easiest way to do this is phpmyadmin. Open the original database and at the top choose export. save as SQL. Now open the new database in phpmyadmin and at the top choose import. Find the sql file you just downloaded from the original live site and upload it here.

Now go get this tool: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

Upload into your www/dev folder. (i usually rename the search and replace folder to SRDB.)

now navigate to dev.example.com/SRDB and the top two lines you'll see a search field and a replace field. in the search place your live site address: www.example.com

in the replace field place your dev url: dev.example.com

hit live live run. ONLY do this after ensuring your on your dev url and that it's loaded into your dev database.

After this runs it's course, you'll have successfully backed up your site, database and have a functioning dev site to mess with that won't mess with your live site.

As a side note. If you can avoid running live and dev on the same server, i usually recommend that just to avoid confusion and to note that if you have any backup programs running on your live site it may include the new dev folder in the backup if you don't exclude it from the back up.

  • It a really good explain. Thanks for you answer and for your time. – dperezac Dec 2 '16 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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