wp_add_trashed_suffix_to_post_name_for_trashed_posts() - WordPress 函数参考中文文档

返回介绍

wp_add_trashed_suffix_to_post_name_for_trashed_posts()

发布于 2017-09-11 字数1973 浏览 826 评论 0

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( string $post_name,  string $post_ID )

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


描述

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

For internal use.


参数

$post_name

(string)
(Required)
Slug.

$post_ID

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


源代码

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 );
		}
	}
}

更新日志

Version 描述
4.5.0 Introduced.

相关函数

Uses

  • wp-includes/post.php:
    wp_add_trashed_suffix_to_post_name_for_post()
  • wp-includes/post.php:
    get_posts()

Used By

  • wp-includes/post.php:
    wp_insert_post()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!