WordPress教學 – 指令工具 WP-CLI

透過下指令就可以看到 mysql 裡 wordpress 裡的相關資料,在某些情況下是滿方便的。

資料來源:
https://make.wordpress.org/cli/handbook/installing/

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

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

Then, check if it works:

php wp-cli.phar --info

To be able to type just wp, instead of php wp-cli.phar, you need to make the file executable and move it to somewhere in your PATH. For example:

chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

Now try running wp --info.


然後到 wordpress 的根目錄下去執行 wp 就可以讀到該站台對應的 mysql 裡的資料。如果你是用 root 權限去執行,參數要多帶 –allow-root

 

列出 user 的指令:

$ wp user list
+----+------------+--------------+------------------+---------------------+---------------+
| ID | user_login | display_name | user_email | user_registered | roles |
+----+------------+--------------+------------------+---------------------+---------------+
| 8 | abc | abc | [email protected] | 2015-05-06 22:46:05 | subscriber |
| 1 | admin | admin | [email protected] | 2015-05-06 22:12:21 | administrator |
+----+------------+--------------+------------------+---------------------+---------------+

 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *