Common operations CLI WordPress commands

This is a list that I will be updating of the most common operations I perform with WordPress CLI. What is WP CLI? It is the execution of WordPress commands in a console.

Reasons for using WordPress CLI

.

Why use WordPress CLI? Using the command line is usually done is because there are certain operations that can take a long time and over the web would not be possible due to the time-out.

This happens especially on web pages with thousands of posts and when there are image operations.

List of CLI WordPress Commands

.

Database backup

.
wp db export

User management: creation and listing

.

Useful when you have console access, but have not yet been given WordPress access. It’s happened to us more than once

.

wp user create davidperez david@close.marketing --role=administrator

Official documentation: wp user create

List users:

wp user list
.

Official documentation: wp user list

Importing XML content

.

Importing entries with XML with wp import. EYE use export before so that it also includes featured images with this plugin.

wp import example.wordpress.2016-06-21.xml --authors=create
.

Regenerate thumbnail images

.
wp media regenerate
.

Official documentation: wp media regenerate

Delete blog posts before a date

.
wp post delete $(wp post list --post_type='post' --date_query='before=2021-01-01' --format=ids)
wp post list --post_type='post' --before="2021-01-01T00:00:00:00"
wp post list --before="2020-12-31T00:00:00:00"

Make a user Super admin

.
wp super-admin add closemarketing
.

Change password to a user

.
wp user update USER --user_pass=###

Deja un comentario

ÚLTIMOS ARTÍCULOS

Cierre Ventana

Analiza tu código automáticamente con PHPSTAN

En proyectos de WordPress, mantener un código limpio y libre de errores es fundamental para garantizar la calidad,…

Cierre Ventana

Desarrolla y crea Test para que tus plugins no tengan errores

Este es el tutorial que vamos a tener en cuenta para la charla de la WordCamp Galicia 2025.…

Cierre Ventana

A great year on the WordPress plugin team

It’s been a great year for the WordPress Plugins Team. You can see the numbers in a summary…

Este sitio está registrado en wpml.org como sitio de desarrollo. Cambia a una clave de sitio de producción en remove this banner.