For development purpose I need to constantly fill and unfill a Wordpress instance with dummy content. Deleting everything in two steps is quite annoying, so I'm wondering if there's a way to cut the long way around to trash when deleting posts. Please help.


3 Answers 3


Considering this site is WordPress Development, I'm assuming you would like to know how to (force) delete posts programmatically.

wp_delete_post(257, true); // `true` indicated you would like to force delete (skip trash)

More on wp_delete_post() function


You can set a time interval for automatically empty trash:

In your wp-config.php put:

define('EMPTY_TRASH_DAYS', 1 ); //Integer is the amount of days

EDIT: To disable trash set the number of days to zero (http://codex.wordpress.org/Editing_wp-config.php)

Hope it helps!

  • 3
    To make instant deletion work this has to be set to 0. Jun 3, 2014 at 13:18
  • @ialocin - Setting define( 'EMPTY_TRASH_DAYS', 0 ); only turns off automatic deletion. Items then stay in trash forever if not deleted manually.
    – leymannx
    Jun 3, 2014 at 13:31
  • 1
  • @koivo "To disable trash set the number of days to zero. Note that WordPress will not ask for confirmation when someone clicks on "Delete Permanently"." It is from codex. Jun 3, 2014 at 13:39
  • @ialocin - Please try it yourself. It only switches off automatic deletion. I've read the docs.
    – leymannx
    Jun 3, 2014 at 13:40

Using WP-CLI this can be achieved pretty easily combining wp post list and wp post delete with the --force option to skip the trash bin like so:

# Delete all posts skipping trash
$ wp post delete $(wp post list --post_type='post' --format=ids) --force

Other examples:

# Delete post skipping trash
$ wp post delete 123 --force
Success: Deleted post 123.

# Delete all pages
$ wp post delete $(wp post list --post_type='page' --format=ids)
Success: Trashed post 1164.
Success: Trashed post 1186.

# Delete all posts in the trash
$ wp post delete $(wp post list --post_status=trash --format=ids)
Success: Deleted post 1268.
Success: Deleted post 1294.
  • This doesn't work if you have WPML
    – FooBar
    Nov 5, 2019 at 12:56
  • @FooBar – Why ?
    – leymannx
    Nov 5, 2019 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.