do_feed()
Load the feed template from the use of an action hook.
描述
If the feed action does not have a hook, then the function will die with a message telling the visitor that the feed is not valid.
It is better to only have one hook for each feed.
源代码
File: wp-includes/functions.php
function do_feed() {
global $wp_query;
$feed = get_query_var( 'feed' );
// Remove the pad, if present.
$feed = preg_replace( '/^_+/', '', $feed );
if ( $feed == '' || $feed == 'feed' )
$feed = get_default_feed();
if ( ! has_action( "do_feed_{$feed}" ) ) {
wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) );
}
/**
* Fires once the given feed is loaded.
*
* The dynamic portion of the hook name, `$feed`, refers to the feed template name.
* Possible values include: 'rdf', 'rss', 'rss2', and 'atom'.
*
* @since 2.1.0
* @since 4.4.0 The `$feed` parameter was added.
*
* @param bool $is_comment_feed Whether the feed is a comment feed.
* @param string $feed The feed name.
*/
do_action( "do_feed_{$feed}", $wp_query->is_comment_feed, $feed );
}
更新日志
Version | 描述 |
---|---|
2.1.0 | Introduced. |
相关函数
Uses
-
wp-includes/functions.php:
do_feed_{$feed} -
wp-includes/l10n.php:
__() -
wp-includes/query.php:
get_query_var() -
wp-includes/functions.php:
wp_die() -
wp-includes/plugin.php:
has_action() -
wp-includes/plugin.php:
do_action() -
wp-includes/feed.php:
get_default_feed()
Show 2 more uses
Hide more uses
User Contributed Notes
你可能对这些文章感兴趣:
- wordpress函数esc_html_x()用法示例
- wordpress函数esc_html()用法示例
- wordpress函数esc_html_e()用法示例
- wordpress函数esc_attr_x()用法示例
- wordpress函数esc_attr__()用法示例
- wordpress函数esc_attr_e()用法示例
- wordpress函数esc_attr()用法示例
- wordpress函数enqueue_embed_scripts()用法示例
- wordpress函数ent2ncr()用法示例
- wordpress函数enqueue_comment_hotkeys_js()用法示例
- wordpress函数edit_user()用法示例
- wordpress函数email_exists()用法示例
- wordpress函数endElement()用法示例
- wordpress函数edit_term_link()用法示例
如有疑问,请前往问答中心反馈!
反馈