# 安装wp cli(国内需要翻墙,下面的方法适合所有平台)
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
如果用mac可通过brew安装
brew install wp-cli
上面已经得到命令 wp,通过wp这个命令可以做很多事情
通过命令行安装wordpress
wp core install --url="your_domain" --title="Blog Title" --admin_user="admin username" --admin_password="enter_your_password" --admin_email="enter_your_email"
# 安装主题
wp theme install twentyten
# 安装插件
wp plugin install woocommerce
生成wordpress 插件代码脚手架 Generate a new plugin with unit tests
$wp scaffold plugin sample-plugin
Success: Created plugin files.
Success: Created test files.
生成wordpress主题脚手架 Generate theme based on _s
$ wp scaffold _s sample-theme --theme_name="Sample Theme" --author="John Doe"
Success: Created theme 'Sample Theme'.
# Generate code for post type registration in given theme
$ wp scaffold post-type movie --label=Movie --theme=simple-life
Success: Created /var/www/example.com/public_html/wp-content/themes/simple-life/post-types/movie.php
更多内容请参考
https://developer.wordpress.org/cli/commands/scaffold/