Cheatsheet de Comandos para WP-CLI

Guardar artículo

Ayuda

Zsh
wp help
wp help theme
wp help theme install
wp help widget
wp help menu
wp help menu location
wp help menu item
wp help post-type
wp help post
wp help post create
wp help post generate
wp help comment
wp help comment delete
wp help term
wp help term list
wp help media
wp help media regenerate
wp help media import
wp help role
wp help role create
wp help user
wp help user create
wp help user generate
wp help user import-csv
wp help option
wp help option patch
wp help cache
wp help cache get
wp help db
wp help db query
wp help db search
wp help db clean

Core de WordPress & Modo Mantenimiento

Zsh
wp core
wp core version
wp core version --extra
wp core check-update
wp core update
wp core update-db
wp core update --version=5.5.3 --force

wp maintenance-mode activate
wp maintenance-mode deactivate
wp maintenance-mode is-active
wp maintenance-mode status

Instalar WordPress

Zsh
wp core download
wp core config --dbname= --dbuser= --dbpass= 
wp core install
wp core install --url= --title= --admin_user= --admin_email
wp config set table_prefix any_prefix_

Tema

Zsh
wp theme status
wp theme delete twentytwentyone twentytwentytwo
wp theme install twentytwentyone
wp theme update --all
wp theme mod list

Plugins

Recuerda reemplazar akismet por el slug del plugin correspondiente.

Zsh
wp plugin status
wp plugin activate akismet
wp plugin deactivate --all
wp plugin install akismet --activate
wp plugin uninstall akismet
wp plugin delete akismet
wp plugin toggle akismet
wp plugin search SEO
# Obtener más info sobre plugin:
wp plugin get akismet

Comentarios

Zsh
wp comment list --number=25
wp comment list --status=hold --fields=comment_ID, comment_content
wp comment spam $(wp comment list --status=hold --format=ids)
wp comment approve $(wp comment list --status=hold --format=ids)
wp comment count
wp comment list --status=spam --fields=comment_ID, comment_content
wp comment delete $(wp comment list --status=spam --format=ids) --force

Usuarios

Zsh
wp user list
wp user create jane jane@test.com --role=proofreader
wp user reset-password jane
wp user get jane
wp user list-caps jane | sort
wp user session list jane@test.com
wp user generate --count=5 --role=proofreader | wp user generate --count=5 --role=editor
wp user import-csv /localpath/test/users.csv
wp user meta list jane
wp user meta update jane first_name 'Jane'
wp user meta update jane last_name 'Doe'
wp user meta update jane description 'Head of proofreading department'
wp user meta delete jane whatever_fieldname
wp user update USER --user_pass=PASSWORD

Roles

Zsh
wp role list
wp cap list thePluginName
wp cap list thePluginName | sort
wp cap list administrator | sort
wp role create proofreader Proofreader --clone=editor
wp cap list proofreader | sort
wp cap remove proofreader delete_published_pages delete_published_posts edit_published_pages publish_pages publish_posts
wp role reset author

Base de Datos

Zsh
wp db optimize
wp db repair
wp db clean
wp db reset
wp db prefix
wp db size
wp db tables
wp db tables --all-tables
wp db columns wp_posts
wp db columns wp_postmeta
wp db search 'STRING TEXT' --all-tables
# Abrir la interfaz de línea de comandos de MySQL:
wp db cli
Zsh
wp db query 'DESCRIBE wp_options'
wp db query 'SELECT * FROM wp_options WHERE option_name="home"'
wp db query "SELECT ID, post_title, post_date FROM wp_posts WHERE post_type='post' ORDER BY ID DESC LIMIT 0, 20"
wp db query "SELECT ID, post_title, meta_key, meta_value FROM wp_posts INNER JOIN wp_postmeta ON ID = post_id WHERE post_type='post' ORDER BY ID DESC LIMIT 0, 20"
wp db query "SELECT wp_comments.comment_id, comment_approved, meta_key, meta_value FROM wp_comments INNER JOIN wp_commentmeta ON wp_comments.comment_ID = wp_commentmeta.comment_ID WHERE comment_approved='spam' LIMIT 0, 10"
wp db query "DELETE wp_comments, wp_commentmeta FROM wp_comments INNER JOIN wp_commentmeta ON wp_comments.comment_ID = wp_commentmeta.comment_ID WHERE comment_approved='spam'"

# EJEMPLO QUERY SELECCION SIMPLE:
wp db query "SELECT user_activation_key FROM wp_users WHERE ID='24'"

# EJEMPLO QUERY SELECCION DE 2 COLUMNAS:
wp db query "SELECT user_nicename, user_activation_key FROM wp_users"

WP Option

Zsh
wp option list
wp option get active_plugins
wp option get posts_per_rss
wp option update posts_per_rss 300
wp option get siteurl
wp option list --search="*rss*"
wp option add example_entrie value7
wp option delete example_entrie
wp option pluck active_plugins akismet
wp option delete core_updater.lock

Menu, Sidebar & Widgets

Zsh
wp menu create My Footer
wp menu location list
wp menu list
wp menu location assign my-footer footer_menu
wp sidebar list
wp widget list sidebar-1
wp widget add calendar sidebar-1
wp widget move calendar-1 --position=4 —sidebar-id=sidebar-1

Caché

Zsh
wp cache flush
wp transient list
wp transient delete --all
wp rewrite list
wp rewrite flush
wp embed fetch https://youtubeurl.com/dfneinsx09w
wp embed cache clear 55692

Posts

Zsh
wp post-type list
wp post-type get product
wp post list
wp post list --posts_per_page=10
wp post list --post_type=page
wp post list --tag=wpcli
wp post term add 8521 category wpcli
wp post create --post_title='Why CPCLI is great'
wp post generate --count=10
curl -N http://loripsum.net/api/5 | wp post generate --post_content --count=10
wp post meta list 55692
# mover al basurero:
wp post delete $(wp post list --post_type='revision' --format=ids)
# borrar definitivamente:
wp post delete $(wp post list --post_type='revision' --format=ids) --force

Términos y taxonomías

Zsh
wp taxonomy list
wp taxonomy list --public=1
wp term list category
wp term create post_tag wpcli
wp term update post_tag 4047 --name=WPCLI
wp term list post_tag
wp term migrate 4047 --from=post_tag --to=category

Media & Search and Replace

Zsh
wp media image-size
wp media regenerate --only-missing --yes
wp media import https://URL-IMG.jpg  --post_id=18 --featured_image
wp media import /Users/desktop-user/Desktop/images/*.jpg

wp search-replace 'old string' 'new string'

Woocommerce

Recuerda reemplazar 123 por el ID del producto y admin por el nombre de usuario o ID del administrador.

Zsh
wp wc product list --user="admin"
wp wc product create --name="New Product" --type="simple" --sku="test-sku" --regular_price="19.99" --user="admin"
wp wc product update 123 --regular_price="24.99" --user="admin"
wp wc product delete 123 --user="admin" 

Recursos Adicionales

Recomendados:

ProveedorAlojamiento & Dominio
Anuncio - Hosting Web de SiteGround - Diseñado para una fácil administración web. Haz clic para saber más.
PluginConstructor Visual
Elementor
PluginOptimización de Velocidad
WP Rocket
PluginSEO
SEOPress WordPress SEO plugin
TemaWordPress & WooCommerce
WordPress Theme: Betheme
PluginSeguridad y Anti-malware
Malcare. WordPress Security
PluginWP Marketplace
Dokan

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *