Linux command
wp 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Show WordPress info
wp --info
Update WordPress core
wp core update
Install plugin
wp plugin install [plugin-name]
Activate plugin
wp plugin activate [plugin-name]
Install theme
wp theme install [theme-name]
Create user
wp user create [username] [email@example.com] --role=[editor]
Search/replace in database
wp search-replace [old-url] [new-url]
Export database
wp db export [backup.sql]
说明
wp (WP-CLI) is the official command-line interface for WordPress administration. It provides complete control over WordPress installations from the terminal, including core updates, plugin and theme management, user administration, and database operations. Common workflows include installing and activating plugins, creating users with specific roles, exporting and importing databases, and performing search-replace operations across the database for tasks like domain migration. The tool can also manage posts, pages, comments, and virtually every aspect of a WordPress site without needing a web browser.
参数
- core
- WordPress core installation and updates.
- plugin
- Plugin management (install, activate, deactivate, update, delete).
- theme
- Theme management (install, activate, update, delete).
- user
- User management (create, list, update, delete).
- db
- Database operations (export, import, query, optimize, repair).
- search-replace _old_ _new_
- Search and replace strings in the database.
- cache
- Object cache commands (flush, type).
- config
- Configuration file management (create, get, set).
- post
- Post management (create, list, update, delete).
- media
- Media attachment management (import, regenerate).
- --path=_DIR_
- Path to WordPress installation.
- --url=_URL_
- Target site URL (for multisite).
- --skip-plugins
- Skip loading all plugins.
- --skip-themes
- Skip loading all themes.
- --user=_USER_
- Run command as a specific user.
- --allow-root
- Allow running as root (not recommended).
FAQ
What is the wp command used for?
wp (WP-CLI) is the official command-line interface for WordPress administration. It provides complete control over WordPress installations from the terminal, including core updates, plugin and theme management, user administration, and database operations. Common workflows include installing and activating plugins, creating users with specific roles, exporting and importing databases, and performing search-replace operations across the database for tasks like domain migration. The tool can also manage posts, pages, comments, and virtually every aspect of a WordPress site without needing a web browser.
How do I run a basic wp example?
Run `wp --info` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does core do in wp?
WordPress core installation and updates.