Wordpress Staging Site

Problem:

I do not want to develop (new features) of a wordpress site on production. So I set up an staging server where the same installation of wordpress is running on.

So while I develop on the staging server on new features, there is content added on production by some other users. Furthermore we use a page builder -> some design is also modified. (We also do some front-end work and using the page builder for some functionalities)

This means, that I cannot simply overwrite the production site with the staging site when the new features are ready - cause I would lose the content which was added (Primarily the ones in the database)

How can I achive that? So the key requirements are:

1) Developing on new features on staging

2) User can add content and change design (with page builder) on live

(I found similar questions, but none of them made me happy :/ )

Topic staging production customization Wordpress

Category Web


There are a couple of options here. One would be to create your own custom database table to store all the development features in. This way, you'd only be pushing that specific table from staging to prod.

Another option is to keep track of what records you're inserting into the staging database, and create a MySQL script to run that will copy the changes to production. As I'm sure you're aware, the media library is its own challenge, so my workaround there is that I normally upload new media directly to the production website and reference those images on staging. That way when I push the new posts from staging to prod, they already reference the correct image - live URL, correct db ID, and so forth.


I fear that there does not exist an answer that is going to make you happy. There is no (easy/good) solution for this problem. In most cases, the production (staging) environment does only touch the code (FTP-files) of a WordPress website, while the live version makes changes to the database (e.g. adding content to it). So normally, when you want to update the live version, you (Git) pull the new version of the website onto the server, and do not touch the database. Additionally, one could change some minor settings within WordPress manually, which will update the database.

However, in the particular case you describe, using Page Builder to develop new features/pages on the staging website, both the staging version and the live variant of the website are making changes to the database.

As far as I know, the only method to update the live website is to find out which database records are updated by Page Builder and add these to the live database manually. The only 'real' solution that I would know of is to create new features in the code itself, but I can see how this might not be a solution for you.

TL;DR: both variants (stage/live) make changes to the database, they have to be merged which is not trivial.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.