• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

I Like Kill Nerds

The blog of Australian Front End / Aurelia Javascript Developer & brewing aficionado Dwayne Charrington // Aurelia.io Core Team member.

  • Home
  • Aurelia 2
  • Aurelia 1
  • About
  • Aurelia 2 Consulting/Freelance Work

Speeding Up Slow WordPress CLI Commands

Wordpress · April 18, 2022

When performing intensive or long-running operations on a WordPress website, the admin panel is terrible. Have you tried to delete 100 posts from the posts screen? It’ll time out and delete maybe 10-20 if you’re lucky. This is one example of many.

Naturally, I opted for the WP CLI (WordPress CLI), which allows you to perform operations on your WordPress site from the terminal. I needed to delete custom post types from within a date range in my use case.

At first, I ran the command, which looked like this:

wp post delete $(wp post list --post_type='news' --posts_per_page=25000 --format=ids --meta_key="story_promoted_from_ingest" --meta_value="0" --start_date=2020-01-01 --end_date=2022-03-31) --force

This worked, but the performance was terrible. I was averaging maybe 20 posts per minute. It was taking forever to delete these. Not able to find a solution quickly, I deep-dived the WP CLI docs and found a heap of flags you can pass to it, most notably --skip-plugins and --skip-themes

What contributed to the slowness was some plugins triggering filters and actions as the posts were deleted.

wp post delete $(wp post list --post_type='news' --posts_per_page=65000 --format=ids --meta_key="story_promoted_from_ingest" --meta_value="0" --start_date=2020-01-01 --end_date=2022-03-31) --force --skip-plugins --skip-themes

By adding those two flags, it was a night and day difference. I was averaging close to 60 per minute (sometimes more). Skipping plugins and themes allows WP CLI to shed weight and run faster. Problem solved.

Dwayne

Leave a Reply Cancel reply

0 Comments
Inline Feedbacks
View all comments

Primary Sidebar

Popular

  • How To Get The Hash of A File In Node.js
  • Testing Event Listeners In Jest (Without Using A Library)
  • Which Neural DSP Archetype Plugins Should You Buy?
  • NBN Box Installed Inside of Garage, Where Do You Put The Modem?
  • Smoke Detector Randomly Goes Off Early Hours of The Morning
  • How to Use Neural DSP Archetype Plugins With the Quad Cortex
  • How to Fast Launch Microsoft Flight Simulator 2020 (decrease game loading time)
  • Wild Natural Deodorant Review
  • How To Install Eufy Security Cameras Without Drilling or Using Screws
  • Perfectly Smoked Steak On A Charcoal BBQ Using Indirect Heat

Recent Comments

  • Thebe on How to Remove the My Sites Menu From the WordPress Admin Bar
  • Maccas worker jn the 2000s on Dear McDonald’s: bring back the Warm Cookie Sundae, you cowards
  • Anamika Singh on Testing Event Listeners In Jest (Without Using A Library)
  • Stefan on A List of WordPress Gutenberg Core Blocks
  • pandammonium on A List of WordPress Gutenberg Core Blocks

Copyright © 2022 · Dwayne Charrington · Log in

wpDiscuz