钩子文档

wp_unique_post_slug_is_bad_hierarchical_slug

💡 云策文档标注

概述

wp_unique_post_slug_is_bad_hierarchical_slug 是一个 WordPress 过滤器,用于判断在分层文章上下文中,给定的文章 slug 是否被视为“不良”。开发者可以通过此过滤器自定义 slug 的验证逻辑。

关键要点

  • 过滤器名称:wp_unique_post_slug_is_bad_hierarchical_slug
  • 用途:过滤判断 slug 在分层文章结构中是否不良,允许开发者干预 slug 的唯一性检查
  • 参数:$bad_slug(布尔值,初始为 false)、$slug(字符串,文章 slug)、$post_type(字符串,文章类型)、$post_parent(整数,父文章 ID)
  • 相关函数:与 wp_unique_post_slug() 配合使用,用于计算文章的唯一 slug
  • 引入版本:WordPress 3.1.0

📄 原文内容

Filters whether the post slug would make a bad hierarchical post slug.

Parameters

$bad_slugbool
Whether the post slug would be bad in a hierarchical post context.
$slugstring
The post slug.
$post_typestring
Post type.
$post_parentint
Post parent ID.

Source

$is_bad_hierarchical_slug = apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent );

Changelog

Version Description
3.1.0 Introduced.