add_trashed_suffix_to_trashed_posts
云策文档标注
概述
本文档介绍 WordPress 中的 add_trashed_suffix_to_trashed_posts 过滤器,用于控制是否为已移至回收站且名称与更新文章匹配的文章添加 __trashed 后缀。该过滤器在 wp_insert_post() 函数中调用,影响文章名称处理逻辑。
关键要点
- 过滤器名称:add_trashed_suffix_to_trashed_posts
- 作用:决定是否向匹配名称的已回收文章添加 __trashed 后缀
- 参数:$add_trashed_suffix(布尔值,是否添加后缀)、$post_name(字符串,更新文章的名称)、$post_id(整数,文章 ID)
- 默认值:true(默认添加后缀)
- 引入版本:WordPress 5.4.0
- 相关函数:wp_insert_post()
原文内容
Filters whether or not to add a __trashed suffix to trashed posts that match the name of the updated post.
Parameters
$add_trashed_suffixbool-
Whether to attempt to add the suffix.
$post_namestring-
The name of the post being updated.
$post_idint-
Post ID.
Source
$add_trashed_suffix = apply_filters( 'add_trashed_suffix_to_trashed_posts', true, $post_name, $post_id );
Changelog
| Version | Description |
|---|---|
| 5.4.0 | Introduced. |