wordpresswp-cli

WP_CLI - how to get / set path


I've installed WP-CLI but it says "This does not seem to be a wordpress installation". The wp keyword works.

So I set path: wp --path '/home/somefolder/okay/websitefolder'

But then it says "No Wordpress installation found". It also says '/home/somefolder/okay/websitefolder' is not a registered wp command.

I also tried setting the path without citation.

I read that there should be a version.php file inside wp-includes, and there is such a file.

I wanted to check what path is currently set, but didn't find any info on how to get global parameter values.


Solution

  • That's no one-time set method. It's just a global parameter you pass to any WP-CLI command to specify the location of a WordPress to work on. See the handbook on Config.

    WP-CLI has a series of global parameters (e.g. --path=<path> and --user=<user>) which work with all commands. They are called global parameters because they affect how WP-CLI interacts with WordPress, and have the same behavior across all commands.

    For example:

    $ wp plugin status --path=/home/somefolder/okay/websitefolder
    

    The alternative is:

    $ cd /home/somefolder/okay/websitefolder
    $ wp plugin status