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=###

Leave a Comment

LAtest articles

Cierre Ventana

How to prepare your plugin for the WordPress.org directory

At the WordCamp Europe in Krakow, Fran Torres and I were speakers. Just after lunch, with the audience…

Cierre Ventana

Preview plugins in WordPress Playground directly from the Pull Request

When someone opens a PR in a WordPress plugin, the usual process for reviewing it involves downloading the…

Cierre Ventana

3 years in the WordPress.org Team Plugins

Yesterday, May 5, 2026, I celebrate 3 years as part of the WordPress.org Plugins Team. And this last…

Logo David
Privacy Resume

Esta web utiliza cookies para que podamos ofrecerte la mejor experiencia de usuario posible. La información de las cookies se almacena en tu navegador y realiza funciones tales como reconocerte cuando vuelves a nuestra web o ayudar a nuestro equipo a comprender qué secciones de la web encuentras más interesantes y útiles.Para más información consulta nuestra <a href="/politica-privacidad/">Política de Privacidad</a>