钩子文档

editable_slug

💡 云策文档标注

概述

editable_slug 是一个 WordPress 过滤器钩子,用于过滤文章或分类的可编辑 slug。它支持多用途,既可用于文章 URI 也可用于分类 slug。

关键要点

  • 这是一个过滤器钩子,允许开发者修改文章或分类的可编辑 slug。
  • 钩子参数包括 $slug(可编辑的 slug 字符串)和 $tag(WP_Term 或 WP_Post 对象)。
  • 在 WordPress 4.4.0 版本中增加了 $tag 参数,最初在 2.6.0 版本引入。

代码示例

$slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';

注意事项

  • 这是一个多用途钩子,具体上下文决定是处理文章 URI 还是分类 slug。
  • 相关函数包括 get_inline_data()、get_sample_permalink() 和 post_slug_meta_box() 等。

📄 原文内容

Filters the editable slug for a post or term.

Description

Note: This is a multi-use hook in that it is leveraged both for editable post URIs and term slugs.

Parameters

$slugstring
The editable slug. Will be either a term slug or post URI depending upon the context in which it is evaluated.
$tagWP_Term|WP_Post
Term or post object.

Source

$slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';

Changelog

Version Description
4.4.0 The $tag parameter was added.
2.6.0 Introduced.