Note:
The instructions in this tutorial are for the Managed WordPress portal clients. These instructions do not apply if you have a Liquid Web WordPress Server Optimized Template account.
cd html
It is always a good idea to create a database backup before making significant changes to your site, like bulk deleting post revisions. To create a manual backup run this command:
wp db export
You can now use gzip to compress the resulting sql file which will mean a smaller file being stored on your server:
gzip sitebackup.sql
wp post delete $(wp post list --post_type='revision' --format=ids)
To delete the post revisions which have been moved to the trash (this includes all post revisions which have a post status of trash), run this command:
wp post delete $(wp post list --post_type='revision' --format=ids --force)
You can skip the first step of moving the posts to the trash by just running the second command. This will remove all post revisions, both those in the trash and those that are in the active portion of the site.
wp package install trepmal/wp-revisions-cli
After the package WP Revisions has been installed, to clean all post revisions, you can use the following command. Please note: this command can be slow, since it will query post revisions before deleting them.
wp revisions clean -1
If you wanted to delete all post revisions before a specific date, you can include that in the command. For example:
wp revisions clean --before-date=2019-06-10
If you needed to clean all post revisions other than those for a specific post type, include that post type at the end of the command. For example, revisions for the WooCommerce created product post type would not be deleted if you run this command:
wp revisions clean --post_type=product
For a faster method to delete all post revisions, you can run this command:
wp revisions dump --hard
To list all existing post revisions, you can run this command:
wp revisions list
Easily deleting post revisions from your site database will help keep the database cleaned up. Streamlining the database can result in performance improvements, especially as the size of the database grows.
wp core verify-checksums
wp core verify-checksums --version=5.2.1
wp core verify-checksums --version=4.9.10
wp plugin verify-checksums --all
wp plugin verify-checksum woocommerce
ln -s /etc/nginx/sites-available/domain.com.conf /etc/nginx/sites-enabled/domain.com.conf
server {
# Temporary redirect to an individual page
rewrite ^/oldpage$ http://www.domain.com/newpage redirect;
}
Permanent Page to Page Redirect
server {
# Permanent redirect to an individual page
rewrite ^/oldpage$ http://www.domain.com/newpage permanent;
}
Permanent www to non-www Redirect
server {
# Permanent redirect to non-www
server_name www.domain.com;
rewrite ^/(.*)$ http://domain.com/$1 permanent;
}
Permanent Redirect to www
server {
# Permanent redirect to www
server_name domain.com;
rewrite ^/(.*)$ http://www.newdomain.com/$1 permanent;
}
Sometimes the need will arise to change the domain name for a website. In this case, a redirect from the old sites URL to the new sites URL will be very helpful in letting users know the domain was moved to a new URL.
The next example we’ll cover is redirecting an old URL to a new URL.
Permanent Redirect to New URL
server {
# Permanent redirect to new URL
server_name olddomain.com;
rewrite ^/(.*)$ http://newdomain.com/$1 permanent;
}
We’ve added the redirect using the rewrite directive we discussed earlier. The ^/(.*)$ regular expression will use everything after the / in the URL. For example, http://olddomain.com/index.html will redirect to http://newdomain.com/index.html. To achieve the permanent redirect, we add permanent after the rewrite directive as you can see in the example code.
When it comes to HTTPS and being fully secure it is ideal for forcing everyone to use https:// instead of http://.
Redirect to HTTPS
server {
# Redirect to HTTPS
listen 80;
server_name domain.com www.domain.com;
return 301 https://example.com$request_uri;
}
After these rewrite rules are in place, testing the configuration prior to running a restart is recommended. Nginx syntax can be checked with the -t flag to ensure there is not a typo present in the file.
Nginx Syntax Check
nginx -t
If nothing is returned the syntax is correct and Nginx has to be reloaded for the redirects to take effect.
Restarting Nginx
service nginx reload
For CentOS 7 which unlike CentOS 6, uses systemd:
systemctl restart nginx
wp plugin list
wp theme list
wp plugin update contact-form-7 --version=5.0.5 --dry-run
In the following example, to rollback Contact Form 7, you can use this command:
wp plugin update contact-form-7 --version=5.0.5
wp plugin install contact-form-7 --version=5.0.5 --activate --force
wp plugin update --all
Excluding A Plugin
If you want to update all plugins, but need to exclude a specific plugin (in this case WooCommerce), run command:
wp plugin update --all --exclude=woocommerce
wp theme update storefront --version=2.4.0
wp theme update storefront
Using a mix of these WP-CLI commands will enable you to easily rollback a plugin on your site, rollback a theme, or update all plugins. It will also update all plugins, but exclude a specific plugin from being updated. Our Managed WordPress product comes with WP-CLI installed along with easy, automatic updates. Check out how our Managed WordPress platform can streamline your work today!