1. 首页
  2. WordPress 函数手册

do_feed()

do_feed()

使用动作挂钩加载提要模板。
Load the feed template from the use of an action hook.

目录锚点:#说明#返回#源码


说明(Description)

如果feed操作没有钩子,那么函数将死掉,并显示一条消息,告诉访问者feed无效。

最好每个饲料只有一个钩子。


返回(Return)

无返回值


源码(Source)

/**
 * 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.
 *
 * @since 2.1.0
 *
 * @global WP_Query $wp_query Used to tell if the use a comment feed.
 */
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();

	$hook = 'do_feed_' . $feed;
	if ( ! has_action( $hook ) )
		wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) );

	/**
	 * Fires once the given feed is loaded.
	 *
	 * The dynamic hook name, $hook, refers to the feed name.
	 *
	 * @since 2.1.0
	 *
	 * @param bool $is_comment_feed Whether the feed is a comment feed.
	 */
	do_action( $hook, $wp_query->is_comment_feed );
}
更新版本 源码位置 使用 被使用
2.1.0 wp-includes/functions.php:1534 0 7

do_feed() 为WP2原创文章,链接:https://www.wp2.cn/functions/do_feed/

发表评论

您的电子邮箱地址不会被公开。