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() WordPress Function

The wp_add_trashed_suffix_to_post_name_for_post() function is used to add a suffix to the post name when a post is trashed. This function is useful for keeping track of which posts have been trashed.

wp_add_trashed_suffix_to_post_name_for_post( WP_Post $post ) #

Adds a trashed suffix for a given post.


Description

Store its desired (i.e. current) slug so it can try to reclaim it if the post is untrashed.

For internal use.


Top ↑

Parameters

$post

(WP_Post)(Required)The post.


Top ↑

Return

(string) New slug for the post.


Top ↑

Source

File: wp-includes/post.php

function wp_add_trashed_suffix_to_post_name_for_post( $post ) {
	global $wpdb;

	$post = get_post( $post );

	if ( '__trashed' === substr( $post->post_name, -9 ) ) {
		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 ↑

Changelog

Changelog
VersionDescription
4.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More