* Many of the functions used in here belong in The Loop, or The Loop for the
* RSS container for the bloginfo function.
* 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 get_bloginfo() For the list of possible values to display.
* @param string $show See get_bloginfo() for possible values.
function get_bloginfo_rss( $show = '' ) {
$info = strip_tags( get_bloginfo( $show ) );
* Filters the bloginfo for use in RSS feeds.
* @param string $info Converted string value of the blog information.
* @param string $show The type of blog information to retrieve.
return apply_filters( 'get_bloginfo_rss', convert_chars( $info ), $show );
* Display RSS container for the bloginfo function.
* 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 get_bloginfo() For the list of possible values to display.
* @param string $show See get_bloginfo() for possible values.
function bloginfo_rss( $show = '' ) {
* Filters the bloginfo for display in RSS feeds.
* @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 );
* Retrieve the default feed.
* The default feed is 'rss2', unless a plugin changes it through the
* {@see 'default_feed'} filter.
* @return string Default feed, or for example 'rss2', 'atom', etc.
function get_default_feed() {
* Filters the default feed type.
* @param string $feed_type Type of default feed. Possible values include 'rss2', 'atom'.
$default_feed = apply_filters( 'default_feed', 'rss2' );
return ( 'rss' === $default_feed ) ? 'rss2' : $default_feed;
* Retrieve the blog title for the feed title.
* @since 4.4.0 The optional `$sep` parameter was deprecated and renamed to `$deprecated`.
* @param string $deprecated Unused..
* @return string The document title.
function get_wp_title_rss( $deprecated = '–' ) {
if ( '–' !== $deprecated ) {
/* translators: %s: 'document_title_separator' filter name. */
_deprecated_argument( __FUNCTION__, '4.4.0', sprintf( __( 'Use the %s filter instead.' ), '<code>document_title_separator</code>' ) );
* Filters the blog title for use as the feed title.
* @since 4.4.0 The `$sep` parameter was deprecated and renamed to `$deprecated`.
* @param string $title The current blog title.
* @param string $deprecated Unused.
return apply_filters( 'get_wp_title_rss', wp_get_document_title(), $deprecated );
* Display the blog title for display of the feed title.
* @since 4.4.0 The optional `$sep` parameter was deprecated and renamed to `$deprecated`.
* @param string $deprecated Unused.
function wp_title_rss( $deprecated = '–' ) {
if ( '–' !== $deprecated ) {
/* translators: %s: 'document_title_separator' filter name. */
_deprecated_argument( __FUNCTION__, '4.4.0', sprintf( __( 'Use the %s filter instead.' ), '<code>document_title_separator</code>' ) );
* Filters the blog title for display of the feed title.
* @since 4.4.0 The `$sep` parameter was deprecated and renamed to `$deprecated`.
* @see get_wp_title_rss()
* @param string $wp_title_rss The current blog title.
* @param string $deprecated Unused.
echo apply_filters( 'wp_title_rss', get_wp_title_rss(), $deprecated );
* Retrieve the current post title for the feed.
* @return string Current post title.
function get_the_title_rss() {
$title = get_the_title();
* Filters the post title for use in a feed.
* @param string $title The current post title.
return apply_filters( 'the_title_rss', $title );
* Display the post title in the feed.
function the_title_rss() {
echo get_the_title_rss();
* Retrieve the post content for feeds.
* @param string $feed_type The type of feed. rss2 | atom | rss | rdf
* @return string The filtered content.
function get_the_content_feed( $feed_type = null ) {
$feed_type = get_default_feed();
/** This filter is documented in wp-includes/post-template.php */
$content = apply_filters( 'the_content', get_the_content() );
$content = str_replace( ']]>', ']]>', $content );
* Filters the post content for use in feeds.
* @param string $content The current post content.
* @param string $feed_type Type of feed. Possible values include 'rss2', 'atom'.
return apply_filters( 'the_content_feed', $content, $feed_type );
* Display the post content for feeds.
* @param string $feed_type The type of feed. rss2 | atom | rss | rdf
function the_content_feed( $feed_type = null ) {
echo get_the_content_feed( $feed_type );
* Display the post excerpt for the feed.
function the_excerpt_rss() {
$output = get_the_excerpt();
* Filters the post excerpt for a feed.
* @param string $output The current post excerpt.
echo apply_filters( 'the_excerpt_rss', $output );
* Display the permalink to the post for use in feeds.
function the_permalink_rss() {
* Filters the permalink to the post for use in feeds.
* @param string $post_permalink The current post permalink.
echo esc_url( apply_filters( 'the_permalink_rss', get_permalink() ) );
* Outputs the link to the comments for the current post in an xml safe way
function comments_link_feed() {
* Filters the comments permalink for the current post.
* @param string $comment_permalink The current comment permalink with
echo esc_url( apply_filters( 'comments_link_feed', get_comments_link() ) );
* Display the feed GUID for the current comment.
* @param int|WP_Comment $comment_id Optional comment object or ID. Defaults to global comment object.
function comment_guid( $comment_id = null ) {
echo esc_url( get_comment_guid( $comment_id ) );
* Retrieve the feed GUID for the current comment.
* @param int|WP_Comment $comment_id Optional comment object or ID. Defaults to global comment object.
* @return string|false GUID for comment on success, false on failure.
function get_comment_guid( $comment_id = null ) {
$comment = get_comment( $comment_id );
if ( ! is_object( $comment ) ) {
return get_the_guid( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID;
* Display the link to the comments.
* @since 4.4.0 Introduced the `$comment` argument.
* @param int|WP_Comment $comment Optional. Comment object or ID. Defaults to global comment object.
function comment_link( $comment = null ) {
* Filters the current comment's permalink.
* @see get_comment_link()
* @param string $comment_permalink The current comment permalink.
echo esc_url( apply_filters( 'comment_link', get_comment_link( $comment ) ) );
* Retrieve the current comment author for use in the feeds.
* @return string Comment Author
function get_comment_author_rss() {
* Filters the current comment author for use in a feed.
* @see get_comment_author()
* @param string $comment_author The current comment author.
return apply_filters( 'comment_author_rss', get_comment_author() );
* Display the current comment author in the feed.
function comment_author_rss() {
echo get_comment_author_rss();
* Display the current comment content for use in the feeds.
function comment_text_rss() {
$comment_text = get_comment_text();
* Filters the current comment content for use in a feed.
* @param string $comment_text The content of the current comment.
$comment_text = apply_filters( 'comment_text_rss', $comment_text );
* Retrieve all of the post categories, formatted for use in feeds.
* All of the categories for the current post in the feed loop, will be
* retrieved and have feed markup added, so that they can easily be added to the
* RSS2, Atom, or RSS1 and RSS0.91 RDF feeds.
* @param string $type Optional, default is the type returned by get_default_feed().
* @return string All of the post categories for displaying in the feed.
function get_the_category_rss( $type = null ) {
$type = get_default_feed();
$categories = get_the_category();
if ( 'atom' === $type ) {
if ( ! empty( $categories ) ) {
foreach ( (array) $categories as $category ) {
$cat_names[] = sanitize_term_field( 'name', $category->name, $category->term_id, 'category', $filter );
if ( ! empty( $tags ) ) {
foreach ( (array) $tags as $tag ) {
$cat_names[] = sanitize_term_field( 'name', $tag->name, $tag->term_id, 'post_tag', $filter );
$cat_names = array_unique( $cat_names );
foreach ( $cat_names as $cat_name ) {
$the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
} elseif ( 'atom' === $type ) {
$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) );
$the_list .= "\t\t<category><![CDATA[" . html_entity_decode( $cat_name, ENT_COMPAT, get_option( 'blog_charset' ) ) . "]]></category>\n";
* Filters all of the post categories for display in a feed.
* @param string $the_list All of the RSS post categories.
* @param string $type Type of feed. Possible values include 'rss2', 'atom'.
return apply_filters( 'the_category_rss', $the_list, $type );
* Display the post categories in the feed.
* @see get_the_category_rss() For better explanation.
* @param string $type Optional, default is the type returned by get_default_feed().
function the_category_rss( $type = null ) {
echo get_the_category_rss( $type );
* Display the HTML type based on the blog setting.
* The two possible values are either 'xhtml' or 'html'.
function html_type_rss() {
$type = get_bloginfo( 'html_type' );
if ( strpos( $type, 'xhtml' ) !== false ) {
* Display the rss enclosure for the current post.
* Uses the global $post to check whether the post requires a password and if
* the user has the password for the post. If not then it will return before
* Also uses the function get_post_custom() to get the post's 'enclosure'
* metadata field and parses the value to display the enclosure(s). The
* enclosure(s) consist of enclosure HTML tag(s) with a URI and other
function rss_enclosure() {
if ( post_password_required() ) {
foreach ( (array) get_post_custom() as $key => $val ) {
if ( 'enclosure' === $key ) {
foreach ( (array) $val as $enc ) {
$enclosure = explode( "\n", $enc );
// Only get the first element, e.g. 'audio/mpeg' from 'audio/mpeg mpga mp2 mp3'.
$t = preg_split( '/[ \t]/', trim( $enclosure[2] ) );
* Filters the RSS enclosure HTML link tag for the current post.
* @param string $html_link_tag The HTML link tag with a URI and other attributes.
echo apply_filters( 'rss_enclosure', '<enclosure url="' . esc_url( trim( $enclosure[0] ) ) . '" length="' . absint( trim( $enclosure[1] ) ) . '" type="' . esc_attr( $type ) . '" />' . "\n" );