• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Damien Carbery - Website Development

Getting You Online & Keeping You There

Getting You Online & Keeping You There Get Started
  • Home
  • Services
  • Maintenance Plans
  • Portfolio
  • Blog
  • About Me
  • Contact
You are here: Home / Website Development / Staging site without uploads

Staging site without uploads

Published: August 3, 2020

With two defines and a plugin you can work on a staging site without editing the database or copying uploads.

When making changes to a site it’s safest to edit a staging site instead of the live site. Some hosting services include the ability to create a staging site but for those that don’t, here’s another option.

Copy the files

As the the post title says, we don’t need to copy the uploads – by that I mean files uploaded to wp-content/uploads. After copying WordPress files, plugins and themes to my staging environment (which may be local, on the same hosting area as the live site or somewhere different), I use Bill Erickson’s brilliantly simple BE Media from Production plugin (on GitHub).

Media from live site

Bill’s plugin filters calls related to media and returns a url pointing to the live site.

The easiest way to configure the plugin is to add the following constant to wp-config.php:

define( 'BE_MEDIA_FROM_PRODUCTION_URL', 'https://www.livesite.com' );

The plugin has other options to source some uploads from the staging site (which Bill says he does if changing image sizes and wants the first few pages of archives looking correct).

Override siteurl and home in wp_options table

If I develop a new site on a staging environment and then move it to the live server I always use the interconnect Database Search and Replace script to replace all the staging urls with the live urls.

I could do this after copying a live database to use on a staging site, and I often do, but sometimes I forget. To help with this you can override siteurl and home with two lines in the staging site’s wp-config.php (as described in Editing wp-config.php):

define( 'WP_SITEURL', 'https://stagingsite.com' );
define( 'WP_HOME', 'https://stagingsite.com' );

This won’t change links within page or post content but can be sufficient if I’m only making some small functional changes.

Related Posts

Debugging – Figuring It Out Yourself

Learn how to investigate and fix front and back end WordPress issues. Use browser tools and the Query Monitor plugin to help locate the problem.

WooCommerce Stock Info

List stock levels in WooCommerce

List the stock numbers for each product and variation.

How to use my code snippets

My code snippets are presented as small, single file plugins that are easy to use - you just upload and activate.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Blog Categories

  • Being Green
  • Food
  • Grammar
  • Just Strange
  • Laziness
  • Personal
  • Portfolio
  • Race Reports
  • Shudder
  • Typo
  • Website Development
  • WooCommerce Tips
  • Facebook
  • Twitter

Copyright © 2013–2023 Damien Carbery · Using Genesis Framework · Privacy Policy