wp_add_trashed_suffix_to_post_name_for_post()
Adds a trashed suffix for a given post.
Store its desired (i.e. current) slug so it can try to reclaim it if the post is untrashed.
For internal use.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
String
. New slug for the post.
Usage
wp_add_trashed_suffix_to_post_name_for_post( $post );
- $post(WP_Post) (required)
- The post.
Notes
- Global. wpdb. $wpdb WordPress database abstraction object.
Changelog
Since 4.5.0 | Introduced. |
wp_add_trashed_suffix_to_post_name_for_post() wp add trashed suffix to post name for post code WP 6.5.2
function wp_add_trashed_suffix_to_post_name_for_post( $post ) { global $wpdb; $post = get_post( $post ); if ( str_ends_with( $post->post_name, '__trashed' ) ) { return $post->post_name; } add_post_meta( $post->ID, '_wp_desired_post_slug', $post->post_name ); $post_name = _truncate_post_slug( $post->post_name, 191 ) . '__trashed'; $wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) ); clean_post_cache( $post->ID ); return $post_name; }