Quick Install
Download
wp core download --locale=viConfig
wp config create --dbname=wp_db --dbuser=root --dbpass=passInstall
wp db create && wp core install --url=site.com --title="My Site" --admin_user=admin --admin_email=a@b.comCore & System
Core
wp core versionShow WP versionwp core updateUpdate WordPresswp core update-dbUpdate database tableswp core verify-checksumsVerify file integritywp core is-installedCheck if installedConfig
wp config get DB_NAMEGet database namewp config listList all constantswp config set WP_DEBUG true --rawEnable debugwp config set WP_MEMORY_LIMIT "256M"Set memory limitwp config shuffle-saltsNew security saltsCLI Info
wp cli versionWP-CLI versionwp cli infoSystem infowp cli updateUpdate WP-CLIwp help <command>Command helpGlobal Flags
--path=/path/to/wpWP root directory--url=https://site.comOverride site URL--user=1Run as user--skip-pluginsDisable all plugins--format=jsonOutput format--dry-runPreview without changes--yesSkip confirmationsPlugins & Themes
Plugins
wp plugin install hello --activateInstall & activatewp plugin install ./plugin.zipInstall from ZIPwp plugin activate helloActivatewp plugin deactivate helloDeactivatewp plugin delete helloDeletewp plugin list --status=activeList activewp plugin update --allUpdate allwp plugin search ecommerceSearch repowp plugin verify-checksums helloVerify integrityThemes
wp theme install astra --activateInstall & activatewp theme activate astraActivatewp theme delete twentytwentyfourDeletewp theme listList all themeswp theme update --allUpdate allwp theme mod listList customizationsDatabase
Backup & Restore
wp db export backup.sqlExport databasewp db export - | gzip > bk.sql.gzExport compressedwp db import backup.sqlImport databasewp db reset --yesDelete all tables & recreateMaintenance
wp db checkCheck integritywp db repairRepair tableswp db optimizeOptimize tableswp db sizeDatabase sizewp db tablesList all tableswp db cliOpen MySQL consoleQuery & Search
wp db query "SELECT..."Execute SQLwp db search "keyword"Search all tableswp db prefixGet table prefixOptions
wp option get siteurlGet site URLwp option get blognameGet site titlewp option update siteurl "url"Update site URLwp option list --search=*cache*Search optionsSearch-Replace & Migration
wp db export backup-before.sql
wp search-replace "http://old.com" "https://new.com" --skip-columns=guid
wp cache flush
wp rewrite flushLuon backup truoc. Skip guid de khong lam hong post IDs.
wp search-replace "old" "new" --dry-runXem truoc thay doi ma khong ap dung.
wp search-replace "old" "new" wp_posts wp_postmeta wp_optionsChi thay the trong cac bang cu the.
wp search-replace "old" "new" --export=changes.sqlXuat SQL thay vi ap dung truc tiep.
Users & Posts
Users
wp user create admin a@b.com --role=administratorCreate adminwp user list --role=administratorList adminswp user update 1 --user_pass=newpassReset passwordwp user set-role 1 editorChange rolewp user delete 2 --reassign=1Delete & reassignwp user generate --count=10Generate test usersPosts & Pages
wp post create --post_title="Hello" --post_status=publishCreate postwp post list --post_type=pageList pageswp post update 1 --post_title="New"Update postwp post delete 1 --forcePermanently deletewp post generate --count=100Generate test postswp post meta update 1 key "val"Update metaMedia
wp media import /path/image.jpgImport mediawp media regenerate --yesRegenerate thumbnailswp media regenerate --only-missingMissing sizes onlywp media image-sizeList registered sizesExport / Import
wp exportExport WXR filewp export --post_type=postExport posts onlywp import file.xml --authors=createImport WXRCache & Cron
Cache
wp cache flushFlush all cacheswp transient delete --allDelete all transientswp rewrite flushFlush rewrite ruleswp rewrite flush --hardHard flush (recreate)wp cache typeShow cache typePermalinks
wp rewrite structure '/%postname%/'Post namewp rewrite structure '/%category%/%postname%/'Category + namewp rewrite listList all rulesCron
wp cron testTest if WP-Cron workswp cron event listList scheduled eventswp cron event run hook_nameRun specific eventwp cron event delete hook_nameDelete eventwp cron schedule listList intervalsScaffold
wp scaffold plugin my-pluginGenerate pluginwp scaffold child-theme child --parent_theme=astraChild themewp scaffold post-type moviesCustom post typewp scaffold block my-blockGutenberg blockCommon Patterns
Full Install:
wp core download --locale=vi
wp config create --dbname=wp --dbuser=root --dbpass=pass
wp db create
wp core install --url=site.com --title="Site" --admin_user=admin --admin_email=a@b.comDeploy with Plugins:
wp plugin install woocommerce yoast-seo --activate
wp theme install astra --activate
wp media regenerate --yes
wp rewrite flushReset WordPress:
wp db reset --yes
wp core install --url=site.com --title="Fresh" --admin_user=admin --admin_email=a@b.comGenerate Test Content:
wp user generate --count=5 --role=editor
wp post generate --count=100
wp term generate category --count=20