函数文档

bloginfo_rss()

💡 云策文档标注

概述

bloginfo_rss() 函数用于在 RSS 源中显示博客信息,它会自动去除标签并转换字符,确保内容适合在 RSS 中使用。该函数基于 get_bloginfo() 的参数来检索特定信息。

关键要点

  • 函数 bloginfo_rss() 直接输出 RSS 容器中的博客信息,适用于 RSS 源显示。
  • 参数 $show 为字符串,可选值参考 get_bloginfo(),如 'name' 表示博客标题,'description' 表示博客描述。
  • 内部使用 get_bloginfo_rss() 获取信息,并通过 apply_filters() 钩子 'bloginfo_rss' 允许过滤输出。
  • 与 get_bloginfo() 类似,但专为 RSS 设计,确保内容安全格式化。

代码示例

bloginfo_rss( 'name' );
bloginfo_rss( 'description' );

注意事项

如果需要检索信息用于其他用途而非直接输出,应使用 get_bloginfo() 函数。


📄 原文内容

Displays RSS container for the bloginfo function.

Description

You can retrieve anything that you can using the get_bloginfo() function.
Everything will be stripped of tags and characters converted, when the values are retrieved for use in the feeds.

See also

Parameters

$showstringrequired
See get_bloginfo() for possible values.

More Arguments from get_bloginfo( … $show )

Site info to retrieve. Default empty (site name).

Source

function bloginfo_rss( $show = '' ) {
	/**
	 * Filters the bloginfo for display in RSS feeds.
	 *
	 * @since 2.1.0
	 *
	 * @see get_bloginfo()
	 *
	 * @param string $rss_container RSS container for the blog information.
	 * @param string $show          The type of blog information to retrieve.
	 */
	echo apply_filters( 'bloginfo_rss', get_bloginfo_rss( $show ), $show );
}

Hooks

apply_filters( ‘bloginfo_rss’, string $rss_container, string $show )

Filters the bloginfo for display in RSS feeds.

Changelog

Version Description
0.71 Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Here is the example for displaying the information of blogs.

    For Example,
    ‘name’: Display the blog title.
    ‘description’: Display the blog description.
    ‘url’: Display the blog URL.
    ‘language’: Display the language used on the blog.

    So, Here we are display the Blog Title and Description:

    bloginfo_rss( 'name' );
    bloginfo_rss( 'description' );

    If you need to retrieve this information for use elsewhere, you can use the get_bloginfo() function with the same parameters as mentioned above.