Type something to search...
How to set up a WordPress staging site?

How to set up a WordPress staging site?

A WordPress staging site is a private copy of your live website where you can test updates, new plugins, design changes, and code before your visitors ever see them. You can set one up in three main ways: with your hosting provider's built-in staging tool, with a staging plugin such as WP Staging, or manually by copying your files and database to a subdomain. Once you are happy with the changes, you push them to production or repeat them on the live site.

If you have ever clicked "Update" on a plugin and watched your homepage break, you already understand why staging matters. This article explains what a staging site is, when you need one, and walks through each setup method step by step, including the manual approach for developers who want full control. You will also learn how to keep search engines out of your staging copy and how to push changes back to production safely.

What Is a WordPress Staging Site?

A staging site is a clone of your production (live) site that runs on a separate URL, such as staging.example.com or example.com/staging. It has the same theme, plugins, content, and settings as your live site, but it is isolated. Anything you do on it, from installing a risky plugin to rewriting your theme's templates, has no effect on the real site that your visitors and customers use.

Most professional WordPress workflows use three environments:

  • Local: A copy running on your own computer, used for development.
  • Staging: A copy running on a server that closely matches production, used for testing and client review.
  • Production: The live site that the public visits.

You don't need all three for a small blog, but having at least a staging environment gives you a safety net that a backup alone can't provide. A backup helps you recover after something goes wrong; staging helps you find the problem before it ever reaches your visitors.

Why Do You Need a Staging Site?

A staging site pays for itself the first time it catches a problem. Here are the most common reasons to use one:

  • Testing updates: Major WordPress core, theme, and plugin updates can occasionally conflict with each other. Running them on staging first reveals issues without downtime.
  • Trying new plugins: Some plugins make database changes on activation or clash with your theme. Staging lets you evaluate them risk-free.
  • Design and layout changes: Editing templates in the Site Editor or changing theme.json settings is easier when you can experiment freely.
  • Custom code: Adding snippets to functions.php or building a custom plugin on staging means a fatal error only breaks the copy.
  • PHP version upgrades: Before switching your live site from PHP 8.1 to 8.3, for example, you can test compatibility on staging.
  • Client approval: Agencies and freelancers can share the staging URL with clients for review before launch.

Method 1: Use Your Hosting Provider's Staging Tool

The easiest option by far is a staging feature built into your hosting control panel. Many managed WordPress hosts include one-click staging, and several general hosts that use cPanel offer it through Softaculous or their own dashboards. Hosts that commonly include staging include SiteGround, WP Engine, Kinsta, Cloudways, Bluehost, Hostinger, and Pressable, though exact features vary by plan.

The general process looks like this:

  1. Log in to your hosting dashboard: Find the section for your WordPress site. It might be called "Sites," "WordPress," or "Websites."

  2. Find the staging option: Look for a menu item labeled Staging, Create Staging Copy, or similar.

  3. Create the staging copy: Click the button to create a new staging environment. The host copies your files and database and sets up a separate URL for you.

  4. Log in to the staging site: Use the link your host provides. Your login details are usually the same as your live site, because the database (including users) was copied.

  5. Make and test your changes: Update plugins, edit your theme, or try new features.

  6. Push to live: When you are satisfied, use the host's Push to Live or Deploy button. Many hosts let you choose whether to push only files, only the database, or both.

Things to Watch for with Host Staging

Pushing a full database from staging to live will overwrite anything that changed on the live site after you created the staging copy. On a blog that might be a few comments. On a WooCommerce store it could be orders and customer accounts. If your live site receives new data constantly, push only files, or use a selective push option if your host provides one, and repeat database-dependent settings manually.

Method 2: Use a Staging Plugin

If your host doesn't offer staging, a plugin can create one for you. The most popular choices are:

  • WP Staging: Creates a staging copy in a subfolder of your existing installation with a few clicks. The free version handles cloning; the Pro version adds pushing changes back to live and cloning to a separate domain.
  • Duplicator: Primarily a migration and backup plugin, but you can use it to package your site and install it on a staging subdomain.
  • All-in-One WP Migration: Exports your whole site into a single file that you can import into another WordPress installation acting as staging.
  • BlogVault and InstaWP: Offer hosted staging environments on their own infrastructure, which is useful if your server resources are limited.

Creating a Staging Site with WP Staging

  1. Install the plugin: Go to Plugins > Add New Plugin, search for "WP Staging," then install and activate it.

  2. Open the plugin: Navigate to WP Staging > Staging Sites in your dashboard.

  3. Create a new staging site: Click Create Staging Site. You can give it a name, which becomes the subfolder, such as staging.

  4. Choose what to copy: By default the plugin copies all database tables and files. You can exclude large folders, such as old backup directories, to speed things up.

  5. Start cloning: Click Start Cloning and wait for the process to finish. Larger sites take longer.

  6. Open the staging site: Click the link to your new staging copy. The plugin adds a visible notice in the admin bar so you always know which environment you are in.

Because the staging copy lives on the same server, it shares resources with your live site. That's fine for occasional testing, but heavy tasks on staging can slow down production on smaller hosting plans.

Method 3: Create a Staging Site Manually on a Subdomain

The manual method takes longer, but it works on any host and gives you complete control. It's also the best way to understand what's really happening when a tool creates staging for you. Make a full backup of your live site before starting.

Step 1: Create a Subdomain

In your hosting control panel, create a subdomain such as staging.example.com. In cPanel this lives under Domains. Point its document root to a new, empty folder, for example /home/username/staging.example.com. If your host issues free SSL certificates through Let's Encrypt, make sure the subdomain gets one too.

Step 2: Copy Your Files

Copy all files from your live WordPress directory into the new folder. If you have SSH access, this is the fastest approach:

rsync -av --exclude 'wp-content/cache' /home/username/public_html/ /home/username/staging.example.com/

Without SSH, you can compress your site folder in the File Manager, copy the archive, and extract it in the staging folder.

Step 3: Copy the Database

Create a new, empty database and database user in your control panel. Then export the live database and import it into the new one. With WP-CLI installed, run this from the live site directory:

wp db export ~/live-backup.sql

Then import it from the staging directory after updating wp-config.php (next step):

wp db import ~/live-backup.sql

If you don't have WP-CLI, use phpMyAdmin: select your live database, click Export, then select the new database and use Import.

Step 4: Update wp-config.php

Open wp-config.php in the staging folder and change the database credentials to the new database:

define( 'DB_NAME', 'staging_db' );
define( 'DB_USER', 'staging_user' );
define( 'DB_PASSWORD', 'a-strong-unique-password' );
define( 'DB_HOST', 'localhost' );

While you're there, tell WordPress this is a staging environment. Add these lines above the /* That's all, stop editing! */ comment:

define( 'WP_ENVIRONMENT_TYPE', 'staging' );
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

WP_ENVIRONMENT_TYPE is a core constant that plugins can read with wp_get_environment_type(). Some plugins, such as Jetpack, use it to avoid behaving as if the copy were your live site.

Step 5: Replace the Site URL

Your copied database still contains your live URL in many places, including serialized data stored by plugins and widgets. A plain SQL find-and-replace can break serialized data, so use a tool that handles it correctly. WP-CLI's search-replace command is the safest choice:

wp search-replace 'https://example.com' 'https://staging.example.com' --skip-columns=guid --dry-run

Review the dry-run output, then run the same command without --dry-run to apply the changes. If you don't have WP-CLI, the Better Search Replace plugin does the same job from the dashboard.

Step 6: Log In and Verify

Visit https://staging.example.com/wp-admin/ and log in with your usual credentials. Go to Settings > Permalinks and click Save Changes to flush rewrite rules, then click around the front end to confirm everything loads.

Keep Your Staging Site Private

A staging site that search engines can index creates duplicate content and can confuse visitors who stumble onto it. Take these steps:

  • Discourage search engines: On the staging site, go to Settings > Reading and check Discourage search engines from indexing this site. This adds a noindex directive, but it's a request, not a guarantee.

  • Password-protect the directory: HTTP authentication blocks everyone, including bots, who doesn't know the password. On Apache, add this to the staging site's .htaccess file, after creating an .htpasswd file through your control panel or the htpasswd utility:

AuthType Basic
AuthName "Staging Site"
AuthUserFile /home/username/.htpasswd
Require valid-user

On Nginx, add an equivalent rule inside the staging server block:

location / {
    auth_basic "Staging Site";
    auth_basic_user_file /etc/nginx/.htpasswd;
    try_files $uri $uri/ /index.php?$args;
}
  • Disable outgoing emails: A copied WooCommerce or membership site might send real emails to real customers. Install a plugin such as WP Mail Logging combined with a mail-blocking snippet, or a dedicated tool like Stop Emails, to prevent this.

If you prefer code, this small must-use plugin stops all mail on staging. Save it as wp-content/mu-plugins/sajjad-block-staging-mail.php:

<?php
/**
 * Plugin Name: Block Emails on Staging
 */

add_filter( 'pre_wp_mail', 'sajjad_block_staging_mail', 10, 2 );

function sajjad_block_staging_mail( $return, $atts ) {
    if ( 'production' !== wp_get_environment_type() ) {
        return false;
    }
    return $return;
}

The pre_wp_mail filter short-circuits wp_mail() when it returns anything other than null, so no email leaves the staging server.

  • Deactivate integrations that act on live data: Payment gateways should be switched to test or sandbox mode, and services like newsletter sync or CRM connections should be disabled so staging doesn't create duplicate records.

How to Push Changes from Staging to Live

Once your changes are tested, you need to get them onto production. How you do that depends on what changed:

  • Plugin or core updates: The simplest approach is to repeat the same updates on the live site, now that you know they're safe.
  • Theme or code changes: Copy the changed files, such as your child theme folder or custom plugin, to the live server via SFTP, or deploy them with Git if you use version control.
  • Settings or content changes: These live in the database. Either repeat them manually on live or use your host's or plugin's push feature, keeping in mind that a full database push overwrites newer live data.

Before any push, take a fresh backup of the live site. After pushing, clear any caching plugin or server-level cache, and test key pages, forms, and checkout flows.

Best Practices for WordPress Staging

Refresh staging regularly: A staging site that is months out of date doesn't reflect your real site. Re-clone it before any big round of testing.

Match the server environment: Staging should run the same PHP version, web server, and caching setup as production. Otherwise, a test that passes on staging might still fail live.

Label environments clearly: Use a different admin color scheme under Users > Profile on staging, or rely on a plugin that adds an environment badge to the admin bar, so you never edit the wrong site by accident.

Delete staging when finished: An old, forgotten staging site with outdated plugins is a security risk. Remove it, or keep it updated and password-protected.

Keep secrets separate: Where possible, use different API keys (such as sandbox keys for payment gateways) on staging so tests never touch real accounts.


FAQ: WordPress Staging Sites

A staging site is a private copy of your live WordPress website where you can safely test updates, plugins, themes, and code changes before applying them to the site your visitors see.

No. A backup is a saved snapshot you can restore after something goes wrong, while a staging site is a working copy where you test changes before they go live. You should use both.

Yes. Many hosting plans include staging at no extra cost, the free version of WP Staging can clone your site into a subfolder, and the manual subdomain method only requires access to your hosting account.

Only if search engines index it. Enable the discourage search engines setting under Settings > Reading and protect the staging site with a password to keep it out of search results.

  • Host tools: Use the Push to Live or Deploy button in your hosting dashboard.
  • Plugins: Use a plugin feature such as WP Staging Pro's push option.
  • Manually: Copy changed files via SFTP or Git and repeat settings changes on the live site.

No. A staging site must always have its own separate database. Sharing a database would mean every change on staging instantly affects the live site, which defeats the purpose.

WordPress and many plugins store serialized data that includes string lengths. A plain SQL replace can corrupt that data, so use WP-CLI's search-replace command or a plugin like Better Search Replace instead.


Conclusion

A WordPress staging site gives you a safe place to experiment, test updates, and polish changes before your visitors ever see them. If your host offers one-click staging, that's the quickest path. If not, a plugin like WP Staging or a manual copy on a subdomain works just as well, and the manual route teaches you exactly how WordPress stores its files and data.

Whichever method you choose, keep your staging copy private, stop it from sending real emails, and refresh it before major testing so it truly mirrors production. Pair it with regular backups of your live site, and you'll be able to make changes with confidence instead of crossing your fingers every time you click "Update."

Tags :
Share :

Related Posts

What are the best WordPress security plugins?

What are the best WordPress security plugins?

The best WordPress security plugins for most sites are Wordfence, Sucuri Security, Solid Security, MalCare, All-In-One Security (AIOS), Patchstack, a

Dive Deeper
What is the difference between posts and pages in WordPress?

What is the difference between posts and pages in WordPress?

The main difference between posts and pages in WordPress is that posts are timely, dated entries that appear in your blog feed, archives, and RSS fee

Dive Deeper
How much does it cost to build a WordPress website?

How much does it cost to build a WordPress website?

Building a WordPress website can cost anywhere from roughly the price of a domain and a year of budget hosting, if you do it yourself with free tools

Dive Deeper