Day 2: Managing WordPress Core with WP-CLI

Updating WordPress Core

One of the most common tasks you’ll perform with WP-CLI is updating WordPress core. To check if an update is available, you can use the following command:

wp core check-update

If an update is available, you can update WordPress core using:

wp core update

This command will download the latest version of WordPress and update your installation. If you want to update to a specific version, you can use:

wp core update --version=5.8

Installing and Managing Themes and Plugins

WP-CLI makes it easy to install, activate, and manage themes and plugins. Here are some examples:

  • To install a theme:
wp theme install twentysixteen
  • To install a theme:
wp theme activate twentysixteen
  • To install a plugin:
wp plugin install akismet

You can also update all installed themes and plugins at once using:

wp theme update --all
wp plugin update --all

Managing WordPress Core Versions

WP-CLI allows you to manage different versions of WordPress core. You can roll back to a previous version using:

wp core update --version=5.7

To verify the integrity of your WordPress files, you can use:

wp core verify-checksums

This command checks your WordPress files against the official checksums to ensure they haven’t been modified.

Best Practices

When managing WordPress core with WP-CLI, it’s a good idea to:

  • Regularly check for updates and keep your WordPress installation up to date
  • Test updates on a staging site before applying them to your live site
  • Use version control to track changes to your WordPress files
  • Backup your site before performing any updates or changes

In the next lesson, we’ll explore how to manage content using WP-CLI, including creating and managing posts, pages, and custom post types. Stay tuned!