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

ÚLTIMOS ARTÍCULOS

Cierre Ventana

My Second Year on the WordPress Plugin Review Team

And yes, I've been contributing to WordPress in the Plugins team for two years now. For those who…

Cierre Ventana

State of the Word: Plugins

Photo taken by wordpress.org Yesterday, the new features that WordPress will be working on in the coming year…

Cierre Ventana

New version of Plugin Check Plugin 1.3.0

A new version of Plugin Check Plugin has been released. Version 1.3.0 brings enhancements, including new checks for…

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>