This tutorial assumes you have some prior knowledge of PHPmyAdmin, adding Domains, and copying files.
How-to Create a WP Staging Website:
1. First thing you need to do is to create a subdomain (subdomain.example.com). This allows your staging website to run in a separate folder, not affecting your main website files.
2.Now that you have setup your subdomain, the next step is to copy the database from your live site to your staging site.
Log into phpMyAdmin, and select your current live database, clicking on the Operations tab in the menu bar.
In the Copy Database To box, enter the name of your staging database (if you haven’t created it yet, click “CREATE DATABASE before copying”). Click Go to run the copy, this could take longer on larger databases.
3. After your database has copied, you need to select it from the sidebar on the left and rename the URLs in the database. To do this, click on the SQL tab in the menu bar and add the code below to Run SQL queries.
Remember to update the URL value: NEW_URL = staging.example.com, ORIGINAL_URL = example.com
UPDATE wp_options SET option_value = REPLACE(option_value, 'ORIGINAL_URL', 'NEW_URL');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'ORIGINAL_URL', 'NEW_URL');
UPDATE wp_posts SET guid = REPLACE(guid, 'ORIGINAL_URL', 'NEW_URL');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'ORIGINAL_URL', 'NEW_URL');
4. After copying your database, you need to copy your WordPress files to the staging server.
5. After copying your data, update your wp-config.php file to use your new staging database connection details. You can use FTP to accomplish this, or if you are an expert, you can use Terminal:
cp -a /PATH/TO/INSTALL /PATH/TO/STAGING
6. Remember to add a disallow all to your robots.txt, and/or update your Search Engine Visibility settings or you might be penalized with duplicate content.
Settings > Reading > Search Engine Visibility
Click “Discourage search engines from indexing this site”
Full Stack Developer, Digital Marketer, and InfoSec enthusiast. He received his Bachelor’s Degree from the University of Western Sydney and his Business Diploma from Georgian College before joining various marketing positions in search portals, e-commerce, higher education, and addiction recovery services.Follow @ twitter
Call Tracking using GTM
I’ve noticed onClick tracking can be troublesome and sometimes doesn’t work as expected on WordPress websites, so its never 100% accurate. To get around these errors, I use Google Tag Manager to track call events. How to Track phone calls using Google Tag Manager: 1. If you haven’t already, install GTM on your website. 2…. Read More
Remove unwanted script from WP Header
I’ve noticed that WordPress adds tons of unwanted script to the header. I totally get why, but for highly focused themes, I like to remove as much as I can. This decreases page load times, eliminates render-blocking resources, and optimizes the First Link Priority Rule. The Script Using the script below, add it to your… Read More