You can use wp_delete_post.
To get all posts with the “trash” status:
$trash = get_posts('post_status=trash&numberposts=-1');
Then:
foreach($trash as $post)
wp_delete_post($post->ID, $bypass_trash = true);
Related Posts:
- Primary and Secondary Button Classes
- How to insert a Button or custom text on twentyseventeen header
- Override admin submit_button() functionality
- Remove “Save draft” button without using CSS
- Download a file and scroll to bottom div on button click
- Remove Save Draft & Preview Buttions.. and also Statius: Draft & Visibility: Public
- Add multiple custom buttons with custom links after add to cart button for every product
- Loading elements with a button
- How to align Button on the right of the image on desktop but below the image on mobile
- How can I center the “Buttons” in the WordPresse editor?
- Add button to menu item at the same row
- NavBar Button Clicks (need 2 clicks rather than 1 click)
- Using button from the function submit_button() triggers alert
- Create Button Using Provided Code
- Back button to previous page and breadcrumbs
- Button to execute shorcode [closed]
- PayPal buttons not working after 4.2.4 upgrade
- Button not working?
- submit button not work
- Add popup window to TinyMCE buttons
- Add button to TinyMCE bar without creating a plugin
- How can you change the ‘Insert into Post’ title in the media button?
- How i can i add a split button or list box to the WordPress TinyMCE instance
- Add Button To Top Toolbar in Gutenberg
- Does WP fire delete_post when trashed posts are automatically deleted?
- Custom “Publish” / “Update” button &
- Custom Shortcode and Button not Working after 3.9 update
- Add frontend “Restore” link
- Can I differentiate between “Delete Post Permanently” and “Empty Trash” and do something for each accordingly?
- wp_trash_post not firing
- Header Button Chance Polylang Elementor
- custom post type, hide or disable the trash button in publish meta box
- How to restore permanently trash page? [closed]
- Comment Spammed vs Trashed
- Custom button block doesn’t work
- How can I link a file in admin with a button?
- Login Button CSS
- Dont’t change active Button while I’m listing a category?
- Button not refreshing page
- How to make a search button that will search my website?
- How do I create a custom add media button modal?
- How can Reusable Blocks be fully deleted?
- Remove add to cart icon/view product button woocommerce
- posts comments goes to trash
- add media button is not working
- Redirect customer to login if not logged in when proceeding to checkout
- Customizer AJAX using buttons
- It is possible to add extra button under the ‘publish’ button in the post of wordpress? and how?
- Button inside Custom Meta Box triggering the Update Button
- Add custom button next to native “Apply” button in the edit-tag screen
- “Loadmore” button is not working in buddypress [closed]
- How to retrieve the date on which a post was moved to trash?
- Adding an Archive button to posts page for administrators
- How to edit the default icon of Add Media button?
- SQL Command for restoring trashed comments
- wp_update_post onclick button using ajax
- How to cancel an action hooked to untrash_post? or any hook
- Restrict access to trash, only admin
- How to restore all items from trash
- Add Ajax to rating button
- How can I specify the post status of an untrashed post?
- Menu toggle bar works only on some pages in WordPress
- add share buttons above my posts without plugins
- How to Add a Read-only Textbox With Text in it That Has a Button to Copy it?
- Cannot access $wpdb, comes back NULL
- Script doesn’t trash custom post types. Instead it duplicates the post and generate new versions in the trash
- How to dynamically add the the input text field in widget?
- How to change ‘Move to Trash’ to ‘Move to Draft’ for my blog’s users?
- Post deleted in trash [closed]
- Generate Own Custom CSS Button with icon
- Create special button on WP Tiny MCE Posts Editor for Shortcodes
- Adding a Media Button to the WordPress Content Editor
- Add two button to page and post admin to redirect to : add new & list of (posts – pages) just after saving post or page
- Redirect from wp-admin back to page
- How to add contact seller button in product page
- Add Cancel Button to a Custom Meta Box
- how to send two forms with one click (script ninjaforms id)
- Show only content in page after action click in WordPress admin
- How can i take all ids from untrash_post action?
- Auto-generated excerpt with shortcode and read more button/text link
- How to display a page dependent on a url parameter supplied by a form/button page?
- Hide download button from audio player
- “Listen” button on my main post page
- excerpt button not going to custom post page
- Custom button on custom taxonomy listing page
- WordPress Settings – Custom Button actions
- Make a button change meta_value
- Run Jquery Script after delete post in front end
- Trash a post, send associated comments into the trash bin (change status)
- WP Posts Not Adding Up
- static page with buton that opens collect email form
- Problem deleting posts from trash
- How to insert image from link in TinyMCE
- Woocommerce – Remove ‘Buy Product’ Button + Make Product Thumbnails Clickable
- how to get rid of header banner buttons on child themes [closed]
- Tried everything but Facebook share button won’t load the post thumbnail
- Button generate a random URL [closed]
- Remove Gutenberg Buttons Block
- how can I remove all default settings in Gutenberg blocks? example core/button
- Gutenberg element Button How do I customize the hover and focus effects?