wp_trash_post
and trashed_post
– from source:
function wp_trash_post($post_id = 0) {
if ( !EMPTY_TRASH_DAYS )
return wp_delete_post($post_id, true);
if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
return $post;
if ( $post['post_status'] == 'trash' )
return false;
do_action('wp_trash_post', $post_id);
add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
add_post_meta($post_id,'_wp_trash_meta_time', time());
$post['post_status'] = 'trash';
wp_insert_post($post);
wp_trash_post_comments($post_id);
do_action('trashed_post', $post_id);
return $post;
}
Related Posts:
- Using publish_{custom-post-type} hook for custom post type to update meta doesn’t work
- How to enqueue scripts on custom post add/edit pages?
- Unregister post type from child theme
- flush_rewrite_rules on save_post Does Not Work on First Post Save
- With what hook can I address all posts from all custom post types when they are published?
- What hook should be used to programmatically create a post only when master post is updated?
- How to register custom post types in a plugin?
- Remove “Get Shortlink” button in admin of custom post type
- update_post_meta() whenever custom post type is updated
- Can’t unregister parent theme’s CPT from my child theme
- Insert Multiple Post with Same Publish Button
- How to: Display ACF [fields] on Custom Post Types Utilising WordPress ‘Hooks’? [closed]
- Filter Posts from the Main Query
- Using preg_replace to filter custom textarea
- Get rid of “trash can” for custom post type
- Use remove_meta_box conditionally on custom post type
- wp_trash_post action hook with custom post type
- How do I amend form data before it is saved for a custom post type
- How can I get some of a posts meta data whilst it is still inserting?
- How to recover the post ID earlier in the WP admin hook action “firing” sequence?
- Using `set_transient()` when saving a custom post type
- How to store additional data that is related to core data
- do action inside a class is not working
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- How to correctly get post type in a the_title filter
- How to add a button to custom post type’s posts-page
- How to intercept publish post for a custom post type “event”
- Ordering posts having multiple post-meta date fields
- Admin Post Update Redirection to Posts Screen
- Grossly inefficient wordpress loops!
- specify meta_key / meta_value condition for prev_post_link and next_post_link
- Error after deleting Custom Post Type with a function (no trash used)
- How to make custom post meta wp_editor translatable?
- How to add multiple featured image in meta box in post editor?
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- How to best delete orphan wp_postmeta
- Set a default category – if the user didn’t select one- before creating a post
- Modifying date filter on admin page for custom post type to link to custom field
- WordPress Orderby Numeric Value Not Working
- Where to hook my plugin’s action
- Replace title column in post list with post meta value
- Does WordPress limit the length of slug names for Post Meta or Terms?
- Add custom column in custom post type edit page
- Undefined Variable – Custom Post Type Meta
- Ordering posts in Search & taxonomy by post_meta
- Post image in WordPress not appearing on home page
- Getting meta in editor plugin, and event triggering issue
- Restrict Access to Posts based on Custom User and Post Meta Data
- Limit number of custom posts per taxonomy
- Metabox not show in categories custom post type cmb2
- Custom fields for custom post type
- Show future events based on custom field AND order by date
- Create new custom post and post category of same name
- create custom meta box with default value
- How to Echo Metadata Value in Currency Format
- How to move a post to different post type with all meta data?
- Why do I have to press the “Update” button twice to save my meta box values?
- WP API Response does not show my registered metadata
- How to detect that the save_post hook is calling the callback associated to the current edit post page only
- get_post_meta returns NULL in front-end, but correct result in back-end
- Problem with adding custom post type meta to header by plugin
- Creating alternate meta box context locations
- Meta box data is saved but NOT displayed in the meta box text field. Why?
- Types plugin custom post add_action hooks
- Echo custom post meta from options array
- Value of post meta dropdown is not showing in WordPress
- WP_Meta_Query object with conditionals
- Trying to write shortcode with get_post_meta but isn’t working
- Loading plugin text domain before registering post type
- comments hooks on custom post type
- HM CMB: Post Select Field for CPT ID
- updating one custom meta field only
- Problem Saving Custom Post Type Meta Values
- Title and URL Error in Breadcrumb Navigation for Custom Post Types
- Changing CPT permalink
- Post Click Redirect to Custom URL instead of Single Post Page
- Show posts from WP Custom Post Type selected from a field in a metabox
- Sort custom post archives by a meta value from a different custom post type?
- Get Previous Post based on Custom Field Name, for Custom Post Type
- Saving custom post types post_meta over REST-API fails
- add action save post type and update post meta woocommerce
- get_post_meta not working with variable as a post_id for dynamically get the postid
- Add more custom fields when creating a new custom post type
- Keep br tags from stripping
- Stripe multiple transactions
- Edit is changing my custom’s post type parent id
- Custom Fields as Post Type Options
- Filter Content on all Post Types
- Disable Facebook Comments Automatically On CPT
- Problem with ‘save_post’ hook not running
- WordPress custom post type
- Howto: use existing post_meta as options for a different metabox (checkboxes or list)
- Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
- Change the contents of a dropdown through the admin panel?
- Dynamically change post_parent in every page load?
- Top 30 Songs using Custom Post Type
- Advice Needed for Post Meta Database Efficiency
- fetch meta fields inside a widget
- Custom post type – update_meta not working
- Use a Variable in update_post_meta as the $meta_key