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
- Add a post when another post type is inserting
- Changing CPT permalink
- Creating a custom post type upon registration for a specific user role
- Update main post with same category when creating custom post to update the modified date
- Attaching more than 1 parent (Post) to a media file
- How to return/export only data showing on screen in custom post type view all screen
- Dynamic page for nav items used as filters
- Use WP_query to match post types based on custom field values
- Post Click Redirect to Custom URL instead of Single Post Page
- How to sort by multiple values in a nested WP_Query
- How can I add a meta[] to my custom post type and search by term with the Rest API?
- Show posts from WP Custom Post Type selected from a field in a metabox
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- Peepso: Add extra data field (custom post meta) to postbox
- Where is get_post_meta value located?
- Hook create / update post
- How can I use a custom template to load custom post type posts based on a post_meta value
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- How do I create a customised table list of a custom post type (in the admin area)?
- publish_post action callback not executed, why?
- How to get post by meta value
- Sort custom post archives by a meta value from a different custom post type?
- Bulk trashing post ‘fails’
- Change picture attachment meta of all occurrences of a picture
- Unknown Post Meta Records
- Get Previous Post based on Custom Field Name, for Custom Post Type
- Get meta values from parent post and save in child post
- Saving custom post types post_meta over REST-API fails
- How to properly get the wp_postmeta.meta_value of a custom post type in specifics?
- How do I get all authors posts of a custom post type outside loop
- add action save post type and update post meta woocommerce
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- get_post_meta not working with variable as a post_id for dynamically get the postid
- Custom Function to redirect singular post if specific meta field is empty
- Correct way to register custom post type from external php file?
- How to get post detail based on URL of the post
- Stored meta from attachment, video length?
- Custom post type meta fields missing on save_post_type
- How to save post_status using action save_post?
- WordPress deletes custom posts instead of trash them
- Saving Child Terms on front end not setting parent
- Custom post meta box as a sub form
- Linking posts together with Advanced Custom Fields “both ways”
- Order posts by meta value hiding posts instead of re-ordering
- Metaboxes in Loop
- Custom post type: “transition_post_status” action get title and other fields
- Add more custom fields when creating a new custom post type
- Keep br tags from stripping
- Grab meta data before post is saved
- call a function when insert and update a custom post type
- Custom meta box data not saving
- custom search results – order results differently by post type
- update a posts of other custom post type
- How do I extract the contents of a CPT’s custom field for all posts?
- Stripe multiple transactions
- Why does get_post() not return anything?
- Collect custom post in a calendar
- Storing data in a multidimensional array from dynamically generated foreach loop
- How to get Current week and current date record wp query
- How to get post meta for custom post type and taxonomy
- get_post_meta for Custom Post Type ( CPT )
- Execute code only after user clicks ‘update’ button for CPT being edited
- Delete custom post type metadata without deleting the post in admin area
- Edit is changing my custom’s post type parent id
- Order by post meta value gets random results
- Custom Fields as Post Type Options
- How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?
- Adding Information To All Posts Screen
- Filter Content on all Post Types
- Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
- Disable Facebook Comments Automatically On CPT
- How to add post reference field to a plugin?
- Filter wp_dropdown_categories Per Post Type
- meta query always fails even if data is correct
- Problem with ‘save_post’ hook not running
- Customizing a plugin function using a hook
- WordPress custom post type