before_delete_post
is not called when a post is only trashed.
While wp_delete_post()
can trash posts (if the post is not trashed and its not being forcibly deleted): it does so by calling wp_trash_post()
and exiting the function prior to the triggering the action before_delete_post
.
I’ve tested this, the following function will only ‘die’ when you permanently delete a post, but not when its confined to the trash. The wp_die
is to demonstrate when the call is being made – I do not recommend using it on a live site.
add_action('before_delete_post', 'my_deleted_post');
function my_deleted_post($post_id){
wp_die(var_dump($post_id));
};
The wp_delete_post()
function can be found here (WP 3.3.1)
Related Posts:
- how to enable different number of revisions for different blogs when using WPMU?
- Unable to restore from backup – how to obtain old blog posts?
- WordPress Multisite – Create Default Post and New Category On New Site Install
- How can I have the posts from one word press blog show on the presentation page of another word press site
- Automatically add date to the auto generation of post slug
- Pagination with an array of post objects?
- Permission issue with custom post type – not added to menu – by plugin
- Duplicate Custom Post Type and Taxonomy Slug
- How could I change my Permalink from blog to custom structure? [closed]
- Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
- Take a received feedback item, turn it into a post
- Getting value from get_post_custom
- WP Admin register taxonomy and post type performance
- Add a custom meta box in the post options that loads some html code in the header
- Static posts page with home.php
- Calling Different Custom Post Timestamps in a table
- Admin – create custom post status and display above table
- custom post template file not shown, instead all the time 404.php
- Set static page/post from another blog on same network
- Set Default Category to Username
- How to allow visitors to filter posts by multiple taxonomies
- show custom post type category dropdown sorting result on same page
- Custom Post Type Rewrite To Include Parent Page(s)
- Thumbnail & Category link aside post
- Redirect to another page using contact form 7? [closed]
- How to include my own css in post
- Custom post types related to same custom post type?
- How do I insert a post with custom post type and relate it to a custom taxonomy?
- Dynamically switch template on click
- “about us”, ” contact” sections should be article(post) or page in the simple small Business website?
- How to WP_Query() from multiple blogs and order them?
- Is it possible to customize the post according to post format in single.php?
- Customize rel=canonical tag for single blog post
- a little direction on custom post type
- disable Tab post on nav-menus page (Admin)
- Is it possible to filter the main loop to exclude posts from a specific category?
- Format latest/newest post differently
- Custom taxonomy archive page problem
- Tell WP to use a specific template file in posts
- Is there a way to create a meta box that can be added multiple times to a post dynamically?
- relating business and products with custom taxonomy?
- Best Way to Add UnEditable HTML to Posts
- How do I show posts from another wordpress installation?
- How safe is it to delete old posts edits to save database space?
- Two Custom Post Types with Identical Articles Competing for the same Slug
- Custom Post Type archive
- WordPress custom post type with folder structure in slug
- Using setup_postdata() with multi-dimensional array
- Is codex right on deleting post?
- Display password protected posts to logged in users
- Check if a custom post type has already been created
- WordPress Query Posts From Category Post on Static Page
- Edit multiple custom post types while saving a new or edited post
- Create a custom posts page
- How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
- if in category but only with post meta
- How to get different Related Posts
- How to add convenient buttons for new custom post statuses
- How to allow multiple thumbnail upload for Posts?
- add external project to web site wordpress on production
- Deleted a user with administrator rights. Now all the data/content/images are lost. how to recover them back
- Show custom post with custom categories with specific slug
- register_post_type permalink
- Display the 2nd category name of a custom post type without error if its null?
- Auto delete posts based on content text
- How to call posts under a specific category on static front page?
- Querying another post category to match current post and display in loop
- Custom home page with full post for first one only
- Custom Post Limit for homepage only without plugin?
- Display value of custom field at the beginning of a post
- l accidentally permanently deleted a Draft. There’s any way I can recover it?
- datepicker value in mysql
- Inserting an example of the last 3 post on to the homepage
- Change Author Name to Sitename on Frontend
- Static pages not working
- Optimize CPT-function with a loop
- Add post tags to previously created custom post type
- Can WordPress handle following functionalities?
- Simple Custom Metabox Not Saving
- Get a term each custom post type
- Change default post style to columns
- Post titles and thumbnails as links to custom post types?
- Custom Post Type, post-formats associated to custom post type > 404 archives
- Cannot select certain authors for posts after import
- How to display only one category in a custom post type?
- Adding a custom post type meta field to rss
- How to restore deleted post related with deleted users
- Help with listing current users submitted custom post type in template file
- Delete post from admin but not from database
- why the posts queried from sql is more than those showed on the page?
- Custom Post Type Single Loop Outputting Wrong Post
- add_rewrite_rule and template redirect not working
- Getting post and attached image from subdomain
- Custom post type slideshow background images to insert in a plugin
- Organization of time insensitive content
- Custom Select Query – Selecting the Year?
- Deleting old posts
- How To Use Custom Tax of a Post Type
- How to output all taxonomy links from a custom post type in a menu?
- Prevent duplicate pages from being added