WP_CLI - 如何获取/设置路径

WP_CLI - how to get / set path

我已经安装了 WP-CLI,但它显示 "This does not seem to be a wordpress installation"。 wp 关键字有效。

所以我设置路径:wp --path '/home/somefolder/okay/websitefolder'

但随后显示 "No Wordpress installation found"。它还说 '/home/somefolder/okay/websitefolder' is not a registered wp command.

我也试过设置没有引用的路径

我看wp-includes里面应该有一个version.php文件,居然有这么一个文件

我想查看当前设置的路径,但没有找到任何关于如何获取全局参数值的信息。

这不是一次性设置方法。它只是您传递给任何 WP-CLI 命令的全局参数,用于指定要处理的 WordPress 的位置。请参阅 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.

例如:

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

备选方案是:

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