Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • M Maknep
  • Project information
    • Project information
    • Activity
    • Members
  • Analytics
    • Analytics
    • Value stream
  • Wiki
    • Wiki
  • Activity
Collapse sidebar
  • Lazaridis Ioannis
  • Maknep
  • Wiki
  • Commands to Clean Up and Optimize

Last edited by Lazaridis Ioannis Oct 05, 2020
Page history
This is an old version of this page. You can view the most recent version or browse the history.

Commands to Clean Up and Optimize

These WP-CLI commands are all very handy for basic housekeeping of your site. These commands in WP-CLI can be used daily or weekly to keep your site optimized and free of bloat. *Run these commands from the root directory of each wordpress installation. *

Add this at the end of each command for root prems --allow-root

1. Purging Cache

In this example, object caching is enabled on the site on our Managed WordPress or Managed WooCommerce, if you need to clear the object cache, use: wp cache flush

2. Regenerate Thumbnail Images

If you changed the theme you were using on your site (which might be setting different image sizes), or if you changed the product image sizes in WooCommerce but now need to regenerate all thumbnail images, you can run this command: wp media regenerate --yes

3. Deleting Spam Comments

If you have comments enabled on your site and you want to delete all spam comments. Only run this command if you know that you do have comments marked as spam on your site, then you can run this command: wp comment delete $(wp comment list --status=spam --format=ids)

4. Removing Temp Data from Database

Expired transients can build up if you have a WooCommerce store. If you need to delete any of this temporary data, you can remove it from your database by running the following command: wp transient delete --expired

5. Optimizing a Database

If you want to optimize your site database, you can run this command: wp db optimize

6. Deleting Posts in Trash

If you wanted to delete all posts that are in the trash, only run this command if you have moved posts to the trash, then you could run this command: wp post delete $(wp post list --post_status=trash --format=ids)

7. Deleting Posts in Draft Status

If you did need to delete all posts that are set as draft post status, you could run this command; wp post delete $(wp post list --post_status=draft --format=ids)

8.Delete Posts With Revisions

If you did want to delete all post revision, then you can run this command; wp post delete $(wp post list --post_type='revision' --format=ids)

Clone repository
  • Alerts Notice
  • Analytics
  • Backup
  • Cerber Anti Spam
  • Commands to Clean Up and Optimize
  • Hummingbird
  • Plugins
  • Simple maintenance routine Guide
  • Slider Revolution
  • Smush
  • WP Bakery Page Builder
  • Wordfence
  • Yoast SEO
  • Home
  • Προσθήκη και επεξεργασία σκαφών.
View All Pages