do_feed_{$feed}
云策文档标注
概述
do_feed_{$feed} 是一个动态动作钩子,在特定 feed 模板加载时触发。它允许开发者根据 feed 类型执行自定义操作,如修改输出或添加额外功能。
关键要点
- 钩子名称是动态的,基于 $feed 参数,例如 do_feed_atom、do_feed_rss2。
- 参数包括 $is_comment_feed(布尔值,指示是否为评论 feed)和 $feed(字符串,feed 名称)。
- 在 WordPress 4.4.0 版本中引入了 $feed 参数,最初于 2.1.0 版本引入。
- 与 do_feed() 函数相关,用于加载 feed 模板。
原文内容
Fires once the given feed is loaded.
Description
The dynamic portion of the hook name, $feed, refers to the feed template name.
Possible hook names include:
do_feed_atomdo_feed_rdfdo_feed_rssdo_feed_rss2
Parameters
$is_comment_feedbool-
Whether the feed is a comment feed.
$feedstring-
The feed name.
Source
do_action( "do_feed_{$feed}", $wp_query->is_comment_feed, $feed );