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.
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)
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!
# Delete all posts skipping trash $ wp post delete $(wp post list --post_type='post' --format=ids) --force
# 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.