wp_trash_post
is literal, not dynamic. It doesn’t change and always ends in _post
regardless of actual post type. See wp_trash_post()
:
do_action( 'wp_trash_post', $post_id );
You also should retrieve post and check its type from $post_id
, do not use globals in that fashion because they might refer to entirely different post.
Your second theory refers to entirely different hook in wp_transition_post_status()
:
do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
Note that it doesn’t start with wp_
, however it does contain specific post type in it dymaically, so it will be trash_contact
.
Related Posts:
- 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
- Can’t unregister parent theme’s CPT from my child theme
- How to: Display ACF [fields] on Custom Post Types Utilising WordPress ‘Hooks’? [closed]
- Filter Posts from the Main Query
- Use remove_meta_box conditionally on custom post type
- How do I amend form data before it is saved for a custom post type
- How to recover the post ID earlier in the WP admin hook action “firing” sequence?
- Using `set_transient()` when saving a custom post type
- Using publish_{custom-post-type} hook for custom post type to update meta doesn’t work
- How to store additional data that is related to core data
- do action inside a class is not working
- Create action running on trashed_post hook to modify post_meta value
- Add a post when another post type is inserting
- Hook for post and page load
- How do you use a CPT as the default home page?
- remove custom post type permalink
- Calling a Function After New Post Creation for a WordPress Custom Post Type?
- How to Debug the ‘save_post’ Action?
- How to change “Draft” string for status of custom post type to “Unavailable”?
- Adding a drag and drop re-ordering from a custom post type default list [closed]
- Action hook on Edit custom post type?
- get_query_var() not working in pre_get_posts
- Custom post type save_post action not firing
- Filter for “get_post_type_archive_link()”
- How to correctly get post type in a the_title filter
- How to add a button to custom post type’s posts-page
- Categorise Custom Post Types
- Using preg_replace to filter custom textarea
- How can I add a filter to a particular post format?
- Is there any way to get list of all possible filter hooks for all post types?
- Create new custom post and post category of same name
- Add a custom text to admin footer in a Custom Post Type page
- Get rid of “trash can” for custom post type
- Custom Meta fields Update hook?
- Include php on a specific page template
- Add an Outside Wrapper to my Header and Make it Full Width
- What do the numbers mean at the end of add_action(‘save_post’)…?
- Running a wordpress action when a custom post type term (taxonomy category) is changed
- sortable columns for multiple custom post types not working
- How check if a post is saved from backend or frontend?
- How to build a WordPress post review system beside commenting
- WordPress hook after post content and meta update
- ACF for custom post type archive pages: which hook to use?
- WordPress hook which triggers on post import
- Assigning alternate single-{cpt} template based on blog_id in multisite
- providing access to post_id or post inside functions.php
- Before saving post hook
- Creating alternate meta box context locations
- Make a custom column sortable by a value from a different custom post type
- Types plugin custom post add_action hooks
- wordpress post_where set only for my costum post type
- Loading plugin text domain before registering post type
- How can I get some of a posts meta data whilst it is still inserting?
- add_action ‘init’ from inside a class for custom post types
- What hook can I use to modify custom post data before it is displayed on the page?
- comments hooks on custom post type
- Catch and display error on save_post action
- Limiting actions only to edit.php page for specific custom post type
- Best way to fix bad count on All | Mine | Published
- Title and URL Error in Breadcrumb Navigation for Custom Post Types
- wp_set_object_terms creates taxonomies but does not add custom posts to it
- Add html tot CPT edit screen – no metabox
- Plugin Development using classes – Public & Private Callbacks
- Custom Post Type action on post update
- Show Post Types customized in Template Page
- In child theme, add CPT to custom taxonomy registered in parent theme
- Store a value in global scope after init hook is fired
- Changing CPT permalink
- Update main post with same category when creating custom post to update the modified date
- Dynamic page for nav items used as filters
- Post Click Redirect to Custom URL instead of Single Post Page
- Hook create / update post
- publish_post action callback not executed, why?
- Sort custom post archives by a meta value from a different custom post type?
- Correct way to register custom post type from external php file?
- Keep br tags from stripping
- call a function when insert and update a custom post type
- Execute code only after user clicks ‘update’ button for CPT being edited
- Custom Fields as Post Type Options
- Adding Information To All Posts Screen
- Filter Content on all Post Types
- Filter wp_dropdown_categories Per Post Type
- Customizing a plugin function using a hook
- Hook only specific post type
- What is the proper way implement a global $wp_rewrite?
- Dynamically change post_parent in every page load?
- Custom post type functions.php if statement on action
- add comments custom fields after user is logged in
- How to string lines from the_content() hook in WordPress?
- Redirect drafted post of custom post type to URL?
- Modifying post_type_link hook messing up edit function for a custom post
- Change CPT Edit Target Link for Admin List
- Custom post type template not loading from plugin
- How to display custom taxonomy subpage inside wp menu from a custom post type using add_menu_page() and add_submenu_page?