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
- I’m making a WordPress CF7 Submit Button Text Changer
- why add to cart button suddenly dissapeard
- How to add “Insert/Edit link” button in custom popup tinymce window?
- Add popup window to TinyMCE buttons
- Add button to TinyMCE bar without creating a plugin
- Turn Off Automatic Trash Deletion?
- How to add multiple buttons to TinyMCE?
- 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
- How to add a button to custom post type’s posts-page
- TinyMCE Anchor Button not showing
- wp_delete_post() deletes post instead of moving it to trash
- Remove Trash / Delete option for Custom Post Type / Taxonomy
- Does WP fire delete_post when trashed posts are automatically deleted?
- Remove border radius setting from the Gutenberg button block?
- Adding submit or update button to custom metabox?
- How to add/retrieve the post trash link?
- Editing Screen: Make Update or Publish Button Follow The Page
- trash_post action with Custom Post Type
- Hook and send Woocommerce data after click Place Order button
- Trash bin for categories
- Custom “Publish” / “Update” button &
- Custom Shortcode and Button not Working after 3.9 update
- Comments screen in backend, how to disable Quick Edit | Edit | History | Spam | for non admins
- Adding TinyMCE custom buttons when using teeny_mce_before_init
- How can I hook into existing WordPress Bulk actions?
- How to hook in to bulk trash posts
- How to Make admin Sidebar Menu always be Collapse by code
- WordPress has a trash for users? (Wrong result for count_user, greater than expected)
- Restrict access to the Trash folder in Posts
- how to grab first link in post… and of course call it
- Quicktags on all textarea.. Not working on plugin?
- How to change redirect after moving a page to trash?
- Error after deleting Custom Post Type with a function (no trash used)
- 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
- Add frontend “Restore” link
- What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
- Dynamically create/remove terms in taxonomy when custom post type is published/trashed
- Can I differentiate between “Delete Post Permanently” and “Empty Trash” and do something for each accordingly?
- How to add a column to the Trash page?
- Custom Role can’t trash Custom Post Type
- Can a user with admin role get ‘Sorry, you are not allowed to move this item to the Trash’ error when trashing a post?
- Why trash folder got empty automatically?
- wp_trash_post not firing
- WYSIWYG – Getting the “link” button from HTML mode in Visual mode
- How to remove buttons from gutenberg toolbar
- Header Button Chance Polylang Elementor
- Restore trashed posts with comments
- Display “add to cart” button on every listing in product category page?
- How to create a link to jump to “Leave a comment” part?
- custom post type, hide or disable the trash button in publish meta box
- Deleted pages showing up when querying for child pages
- Adding another “Add Post” button to admin
- How to align a single Gutenberg block button in WP 5.5.3?
- How can I create custom button in post.php
- How to restore permanently trash page? [closed]
- Help add ajax load more button
- How to untrash a post only if it was not a draft?
- Control whether or not to trash a custom post type
- When trashing a post, also trash related comments
- How to use radio buttons in WordPress plugin options using register settings?
- How can I add buttons to a custom column in the taxonomy table?
- Comment Spammed vs Trashed
- Custom button block doesn’t work
- How can I link a file in admin with a button?
- Displaying a button on each post
- Using Multiple Submit buttons to trigger customised php functions
- Deleting the attached “comment replies” when trashing a comment
- How to load javascript file on homepage in WordPress in order?
- Login Button CSS
- Creating a Link Text like Submit Button in Admin Page
- Dont’t change active Button while I’m listing a category?
- Gutenberg Button Border Radius Default
- Insert a button on a page with random number generation
- Shortcode to delete post from front end
- CSS style button For WP Login Function in page template
- Button not refreshing page