---
title: How to Create a WordPress Staging Site and Push Changes Live Safely
description: "How to create a WordPress staging site, keep it out of search, and push changes live without losing posts or orders added since the copy. Tested."
url: "https://skybootstrap.com/wordpress-staging-site/"
canonical_url: "https://skybootstrap.com/wordpress-staging-site/"
date: "2026-11-29T06:45:00+06:00"
modified: "2026-11-16T17:31:31+06:00"
author: Skybootstrap Team
type: article
site: SkyBootstrap
language: en-US
---

# How to Create a WordPress Staging Site and Push Changes Live Safely

A WordPress staging site is a private copy of your site, at its own address and with its own database, where you test changes before visitors see them. Make one with your host’s staging tool, a plugin, or by hand. Then push back only what you changed: in our test, pushing the whole database erased a post written on the live site in the meantime.

We built our staging copy by hand on our own test site, then pushed changes back two ways to see what each one kept and what it lost.

## What a WordPress staging site is

A WordPress staging site is a copy of your live site that only you use. Two things make it a real copy rather than a risk: it has its own address, and it has its own database. Without both, a change on “staging” can land on the live site, which is often called production.

You use staging to try what you’d rather not try in front of visitors: a big plugin update, a new theme, custom code, a redesign. Our guide to updating WordPress safely sends major updates here first.

## Pick a route: your host, a plugin, or a manual copy

Your host, a plugin or a manual copy can each give you a staging site. We tested only the manual copy, built with WP-CLI’s `search-replace` command, so check these points in whichever you use:

- **Your host’s staging tool.** Some hosts have a staging button in their panel; [DreamHost’s guide](https://www.dreamhost.com/blog/website-staging-beginners-guide/), for example, says its DreamPress staging sites are “non-indexable by default”. Find out what its push-to-live button copies (files, database, or both) and whether it saves a backup of the live site before it starts.
- **A staging plugin.** Check where it puts the copy, whether the copy gets its own database tables, and whether pushing back costs extra.
- **A manual copy.** You copy the files and the database yourself and give the copy its own address. It takes more steps, but nothing is hidden, and it’s what we tested below.

These steps are for a single WordPress site. A multisite network needs more changes, which we didn’t test.

## Make a WordPress staging site copy by hand

A manual staging copy needs an address, a database, and a copy of the files; the same steps, minus the push back, also move a site to a new host. You need SSH access and WP-CLI, WordPress’s command-line tool. Without them, use your host’s staging tool or a plugin.

In your hosting panel, create a subdomain such as `staging.example.com` and point it at a new folder outside the live site’s folder, such as `/home/youruser/staging`. If the panel suggests a folder inside `public_html`, change it: when we copied a site into a folder inside itself, `cp` stopped with “cannot copy a directory … into itself”. Check the new folder is empty with `ls -A`. Then create an empty database, and allow the database user your site already uses to work with it.

Before copying, check two things on the live site:

```
wp --path=/home/youruser/public_html option get home
wp --path=/home/youruser/public_html config path
```

The first prints the site’s exact address, with or without `www`; use that text in the search-replace below. The second shows which wp-config.php the site uses. Some sites keep it one folder above `public_html`, where the copy command below won’t reach it.

We tried that layout on a copy of our test site. The staging folder had no settings file of its own, so WP-CLI used the live one, and `config set` changed the live site’s database name. If the path ends outside `public_html`, copy that file into the staging folder after the first command below.

Then run these commands one at a time, changing the folders, database name and addresses to yours. Every `wp` command names its site with `--path`:

```
cp -a /home/youruser/public_html/. /home/youruser/staging/
wp --path=/home/youruser/staging config path
wp --path=/home/youruser/staging config set DB_NAME youruser_staging
wp --path=/home/youruser/public_html db export ~/live-copy.sql
wp --path=/home/youruser/staging db import ~/live-copy.sql
wp --path=/home/youruser/staging search-replace 'https://example.com' 'https://staging.example.com' --skip-columns=guid
wp --path=/home/youruser/staging option update blog_public 0
wp --path=/home/youruser/staging option get home
```

The second command must print the staging folder’s own wp-config.php; if it doesn’t, stop. If the copy has a `wp-content/object-cache.php` file, it would share the live site’s Redis or Memcached cache. Move that file out of the staging copy (`mv /home/youruser/staging/wp-content/object-cache.php ~/`) before the second command; we didn’t test this.

On our test site, copying the files took under a second and the database import 0.2 seconds. The search-replace reported “Made 8 replacements”: 2 in WordPress settings, 5 in post content and 1 in a user profile. If yours reports 0, the address didn’t match; a dry run with the wrong address found “0 replacements to be made”.

The last command should print the staging address. If it prints the live one, stop: logging in to the copy would take you to the live dashboard.

The search-replace step is why the copy works at its new address. WordPress stores the site’s address in its settings and inside content, and some settings hold serialized data, which is saved in a packed format that records each text’s length. WP-CLI’s documentation says its command “intelligently handles PHP serialized data”; a plain text replace in an SQL file doesn’t update those lengths.

Our guide to changing a WordPress domain covers address changes in more depth. `--skip-columns=guid` leaves the guid column, WordPress’s permanent post identifiers, unchanged.

`--path` matters more than it looks. While building our copy, one command in a chain failed before the step that changed folders. The next commands then ran against the live site’s database and pointed the live site at the staging address. We restored it from the backup taken minutes earlier.

Naming the site in every command prevents that.

## Keep the staging site out of search engines

Keep search engines away from staging, or a copy of your site can compete with the real one. The `blog_public 0` command above ticks the **Settings > Reading** checkbox “Discourage search engines from indexing this site”, which tells search engines not to index it. On our staging copy, the homepage then carried a `noindex, nofollow` robots tag, while the live site’s homepage didn’t.

It isn’t a lock. Our staging robots.txt still allowed crawling. The [WordPress documentation](https://wordpress.org/support/article/settings-reading-screen/) says the option asks search engines not to index the site, adding: “it is up to search engines to honor your request.” For real privacy, password-protect the staging address in your hosting panel; we didn’t test that.

## Check the copy doesn’t still use the live site

A copy can look right and still load files from the live site. Ours returned a server error right after copying. The cause was a file the Query Monitor plugin puts in `wp-content`: it was a symlink, which is a shortcut to another file, and it pointed to the live site’s plugin folder by full path. The copy loaded the live plugin’s code next to its own, and PHP stopped with “Cannot declare class”.

This finds every shortcut in the copy that points into the live site:

```
find /home/youruser/staging -type l -lname '/home/youruser/public_html*'
```

Point each one at the staging copy’s own file. For ours, that was:

```
ln -sfn /home/youruser/staging/wp-content/plugins/query-monitor/wp-content/db.php /home/youruser/staging/wp-content/db.php
```

After we relinked ours, the site still failed until PHP was restarted, because PHP had remembered the old target. If the error stays after relinking, ask your host to restart PHP.

Then load a few staging pages and check that links and images point to the staging address. On ours, all 212 links on the homepage did.

## Push staging changes to live

Pushing staging to live means copying your tested change back. What you push decides what you lose. A database push replaces the live database with the staging one; a files push writes only the folders you changed to live. We updated a plugin and changed the site title on staging; meanwhile, we published a new post on the live site. Then we pushed back both ways:

![WordPress staging site diagram: if you changed files such as plugins, themes or code, copy those folders to live and live posts and settings stay; if you changed settings or content, redo them on live or push the database only if live hasn't changed since the copy](https://skybootstrap.com/wp-content/uploads/2026/11/wordpress-staging-site-what-to-push.webp "What to push from staging to live, based on our push tests on WordPress 7.1.4, 11 Nov 2026.")

| What we pushed | The plugin update | The new title | The post written on live | Search engines |
| --- | --- | --- | --- | --- |
| Only the plugin’s folder | Arrived | Not moved | Kept | Unchanged |
| The whole staging database | Not carried (plugin files aren’t in the database) | Arrived | **Gone** | Blocked, until we switched it back |

So push files when the change is in files. To copy one plugin folder from staging to live, move the live one out of the plugins folder, copy the tested one in, and check:

```
cd /home/youruser/public_html/wp-content/plugins &&
mv contact-form-7 ~/contact-form-7.old &&
cp -a /home/youruser/staging/wp-content/plugins/contact-form-7 . &&
wp --path=/home/youruser/public_html plugin list --fields=name,status,version
```

Keep the old folder outside `plugins`. When we left it there as `contact-form-7.old`, WordPress listed a second, inactive Contact Form 7, and the old code stayed inside the website folder. If the site misbehaves, run `rm -rf contact-form-7 && mv ~/contact-form-7.old contact-form-7` from the same folder to go back. Once it works, delete `~/contact-form-7.old`.

Run these as the user that owns the site’s files. On our test site, plugin files written by another user later made dashboard updates fail.

Changes stored in the database, such as settings, menus, widgets and page edits, are safer to redo by hand on live. Only push the database when nothing has changed on live since you made the copy: no new posts, comments, sign-ups or orders. Back up live first. Then, after importing, run the search-replace in the other direction and switch search engines back on:

```
wp --path=/home/youruser/public_html db export ~/live-before-push.sql
wp --path=/home/youruser/staging db export ~/staging-push.sql
wp --path=/home/youruser/public_html db import ~/staging-push.sql
wp --path=/home/youruser/public_html search-replace 'https://staging.example.com' 'https://example.com' --skip-columns=guid
wp --path=/home/youruser/public_html option update blog_public 1
wp --path=/home/youruser/public_html cache flush
```

Right after our import, the live site’s address pointed at staging. The search-replace fixed it with the same 8 changes, and the search-engine block came across from staging until we switched it off.

We tested posts, not shop orders. A store’s orders are stored in the database too, so a database push would overwrite them as well. [Duplicator’s staging guide](https://duplicator.com/wordpress-staging-site/) says “This will automatically push changes on your staging site to your live site!” and suggests a recovery point first. It doesn’t mention posts or orders added on live since the copy, so check what your tool sends.

## Clear the cache and check live after a database push

After a database push, empty the page cache. Our test server keeps pages for 10 minutes.

A homepage cached while the search-engine block was on still carried the `noindex` tag after we switched it off, and after `wp cache flush`, which clears only WordPress’s object cache. The tag went only when we emptied the page cache. Clear your caching plugin, host cache and CDN (we didn’t test a CDN), then check the live homepage:

```
curl -s https://example.com/ | grep -c -e noindex -e staging.example.com
```

It should print 0. Delete the `.sql` files afterwards, since a dump holds your users’ email addresses and password hashes.

If a push goes wrong, our restore guide shows how to put the live backup back. The WordPress maintenance checklist has when to refresh the staging copy.

## How we tested

We made a staging copy of our WordPress 7.1.4 test site at a second address on the same server, with its own database, using WP-CLI 2.12.0 for every database step. After fixing the copy’s shortcut back into the live site, we updated Contact Form 7 and changed the site title on staging while publishing a post on the live site. Then we pushed the plugin folder alone, then imported the whole staging database on top, and restored live from the backup afterwards.

On copies, we also tried a wp-config.php kept above the site folder, a staging folder inside the live one, and the page cache after a push. We didn’t test host staging tools, staging plugins, password protection, an object cache, a multisite or a shop with orders.

## Frequently Asked Questions

### Will pushing staging to live overwrite new orders or posts?

A database push will. In our test, a post published on the live site while we worked on staging was gone after we imported the staging database. Pushing only the changed files, such as a plugin folder, kept it. A shop’s orders are stored the same way, so check what your tool pushes.

### Can I create a WordPress staging site for free?

Yes. A manual copy needs only a subdomain, an empty database and the commands above; on our test site, the copy itself took under a second. Some hosts include staging in their plans too, so check your hosting panel first.

### Should a staging site be on a subdomain or in a subfolder?

A staging site on a subdomain, with its folder outside the live site’s folder, is the simpler choice, and it’s what we tested. Copying the live folder into a folder inside itself failed in our test, and a copy inside the live folder also ends up in backups of it. Whichever you pick, give it its own database.