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 button to TinyMCE bar without creating a plugin
- How can you change the ‘Insert into Post’ title in the media button?
- Add Button To Top Toolbar in Gutenberg
- Remove Trash / Delete option for Custom Post Type / Taxonomy
- Adding submit or update button to custom metabox?
- How to add/retrieve the post trash link?
- Hook and send Woocommerce data after click Place Order button
- Trash bin for categories
- how to grab first link in post… and of course call it
- Undelete post (untrash)?
- Is there an action that is called when a post is restored from the trash?
- get_post() function returns post even if it is trashed
- Exclude trash from save_post
- wp_trash_post not firing
- How to create a link to jump to “Leave a comment” part?
- Deleted pages showing up when querying for child pages
- When trashing a post, also trash related comments
- How can I add buttons to a custom column in the taxonomy table?
- Comment Spammed vs Trashed
- Displaying a button on each post
- Using Multiple Submit buttons to trigger customised php functions
- Login Button CSS
- Gutenberg Button Border Radius Default
- Insert a button on a page with random number generation
- Shortcode to delete post from front end
- How to make a search button that will search my website?
- Firefox CSS Animations Broke [closed]
- Add buttons to the new TinyMCE WP Editor. Javascript API
- It is possible to add extra button under the ‘publish’ button in the post of wordpress? and how?
- show/hide div with simple jQuery script [closed]
- Sort trash by date post was trashed
- “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
- 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
- Script doesn’t trash custom post types. Instead it duplicates the post and generate new versions in the trash
- 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
- Putting a space between the buttons [closed]
- Adding a Media Button to the WordPress Content Editor
- Upload PlugIn Button is missing
- Add two button to page and post admin to redirect to : add new & list of (posts – pages) just after saving post or page
- How to display strikethrough text in button text (for special offer)
- 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
- excerpt button not going to custom post page
- Add Flatr button to Sharing option
- 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
- jQuery to Create Button to Show/Hide WordPress Comments and to Hide Comments by Default
- 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]
- Can I turn an image into a button?
- Dynamic price for payment button
- wp_trash_post not firing as expected (also applies to trashed_post)
- How to use tag in wordpress?
- Add a custom code with custom link after add to cart for every product
- How to prevent users from permanently deleting a post from trash, but allow them to restore it?