钩子文档

self_link

💡 云策文档标注

概述

self_link 是一个 WordPress 过滤器,用于修改当前 feed 的 URL。它允许开发者在输出 feed 链接前进行自定义处理。

关键要点

  • self_link 过滤器应用于当前 feed 的 URL,参数为 $feed_link(字符串类型),代表设置了 URL 方案的 feed 链接。
  • 过滤器函数必须返回一个值,否则结果将为空,确保处理后的链接能被正确输出。
  • 此过滤器在 WordPress 3.6.0 版本中引入,常用于安全地显示当前 feed 链接,例如在 self_link() 函数中。

代码示例

echo esc_url( apply_filters( 'self_link', get_self_link() ) );

注意事项

使用此过滤器时,务必确保过滤器函数返回处理后的值,以避免输出空链接。


📄 原文内容

Filters the current feed URL.

Description

See also

Parameters

$feed_linkstring
The link for the feed with set URL scheme.

More Information

The filter function must return a value after it is finished processing or the result will be empty.

Source

echo esc_url( apply_filters( 'self_link', get_self_link() ) );

Changelog

Version Description
3.6.0 Introduced.