• Install WP-CLI for better WordPress management

    Install WP-CLI for better WordPress management

    When managing a WordPress site, most people rely on the WordPress admin dashboard. While it works well, it can feel slow and limited when you need to perform repetitive or bulk tasks. That’s where WP-CLI comes in — a powerful command-line tool that makes WordPress management faster, more efficient, and scriptable.

    What is WP-CLI

    WP-CLI (WordPress Command Line Interface) is an open-source tool that lets you control and manage your WordPress website directly from the terminal. Instead of clicking through the dashboard, you can run commands to update plugins, manage users, export data, and much more.

    It’s especially useful for developers, sysadmins, and agencies managing multiple sites, as it enables automation and integration with server scripts or deployment workflows.

    Key Features of WP-CLI

    Here are some of the most useful things you can do with WP-CLI. For a complete list of available commands, check the official documentation.

    CommandDescription
    wp core updateUpdates WordPress to a newer version.
    wp plugin listGets a list of plugins.
    wp plugin update --allUpdates all plugins.
    wp cache flushFlushes the object cache.
    wp db exportExports the database to a file.

    Each command includes a set of parameters that you can combine to perform more specific tasks.

    How to Install WP-CLI

    First, download wp-cli.phar using wget or curl. For example:

    sudo curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

    Move the downloaded file to /usr/local/bin/wp:

    sudo mv wp-cli.phar /usr/local/bin/wp

    Make that file executable:

    sudo chmod +x /usr/local/bin/wp

    To confirm that the installation was successful, run the following command to view WP-CLI details:

    wp --info

    If you see something like this, then your installation was successful:

    OS:	Linux...
    Shell:	/bin/bash
    PHP binary:	/usr/bin/php...
    PHP version:	...
    php.ini used:	/etc/php/...
    MySQL binary:	/usr/bin/...
    MySQL version:	...
    SQL modes:
    WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
    WP-CLI vendor dir:	phar://wp-cli.phar/vendor
    WP_CLI phar path:	phar:///usr/local/bin/wp
    WP-CLI packages dir:
    WP-CLI cache dir:	/home/ubuntu/.wp-cli/cache
    WP-CLI global config:
    WP-CLI project config:
    WP-CLI version:	2.12.0

    How to Use WP-CLI

    To use WP-CLI, you must navigate to your WordPress installation directory first by using cd command. For example:

    cd /var/www/public/wordpress

    Then, you can begin to use wp commands from there.

    Done. Now you’re ready to use WP-CLI to manage your WordPress site like a pro.