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

WordPress Day Granada: cybersecurity applied to the real world

Yesterday a conference was held in Granada focused on one of the most critical topics for any digital…

Cierre Ventana

State of the Word 2025 Automatic Scanners in Updates

At the State of the Word 2025 we had the opportunity to learn about the news in the…

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…

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>