Using WordPress ‘get_the_content_feed()’ PHP function

The get_the_content_feed() WordPress PHP function retrieves the post content for feeds.

Usage

$content = get_the_content_feed( $feed_type );

Custom Example:

$content = get_the_content_feed( 'rss2' );
echo $content;

Parameters

  • $feed_type (string, optional) – The type of feed. Can be ‘rss2’, ‘atom’, ‘rss’, or ‘rdf’. Default: null.

More information

See WordPress Developer Resources: get_the_content_feed()

Examples

Display RSS2 feed content

Display the post content for an RSS2 feed.

$content = get_the_content_feed( 'rss2' );
echo $content;

Display Atom feed content

Display the post content for an Atom feed.

$content = get_the_content_feed( 'atom' );
echo $content;

Display RSS feed content

Display the post content for an RSS feed.

$content = get_the_content_feed( 'rss' );
echo $content;

Display RDF feed content

Display the post content for an RDF feed.

$content = get_the_content_feed( 'rdf' );
echo $content;

Display default feed content

Display the post content for the default feed type.

$content = get_the_content_feed();
echo $content;

Tagged in

Leave a Comment

Your email address will not be published. Required fields are marked *