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

The wp_add_trashed_suffix_to_post_name_for_trashed_posts() function is used to add a suffix to the post name for trashed posts.

wp_add_trashed_suffix_to_post_name_for_trashed_posts( string $post_name, int $post_ID ) #

Adds a suffix if any trashed posts have a given slug.


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_name

(string)(Required)Post slug.

$post_ID

(int)(Optional) Post ID that should be ignored. Default 0.


Top ↑

Source

File: wp-includes/post.php

function wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID = 0 ) {
	$trashed_posts_with_desired_slug = get_posts(
		array(
			'name'         => $post_name,
			'post_status'  => 'trash',
			'post_type'    => 'any',
			'nopaging'     => true,
			'post__not_in' => array( $post_ID ),
		)
	);

	if ( ! empty( $trashed_posts_with_desired_slug ) ) {
		foreach ( $trashed_posts_with_desired_slug as $_post ) {
			wp_add_trashed_suffix_to_post_name_for_post( $_post );
		}
	}
}


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