Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

wp_add_trashed_suffix_to_post_name_for_post( WP_Post $post ): string

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.

Top ↑


$post WP_Post Required
The post.

Top ↑


string New slug for the post.

Top ↑


File: wp-includes/post.php. View all references

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;

Top ↑


Version Description
4.5.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.