WordPress the_feed_link() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Prints a link

Definition

In WordPress, the_feed_link() prints a link to your site feed. A feed (RSS or Atom) lets people follow your posts in a feed reader.

You give the text of the link, such as Subscribe to posts. WordPress adds the correct feed address. The feed type is optional, and the default is the standard RSS 2.0 feed.

Syntax

Give the text of the link.

WordPress
<?php the_feed_link( 'Subscribe to posts' ); ?>
CallWhat it does
the_feed_link( 'Subscribe' )Link to the default RSS feed.
the_feed_link( 'Atom feed', 'atom' )Link to the Atom feed.
the_feed_link( 'RSS', 'rss2' )Link to the RSS 2.0 feed.

It prints a full a tag. If you only need the feed URL, use get_feed_link().

Full declaration
WordPress
the_feed_link( string $anchor, string $feed = '' ): void

Parameters

ParameterDescription
$anchorstring. The visible text of the link. It is required.
$feedstring. The feed type: rss2, atom, rdf, or rss. Default is empty, which means the default feed.

Return Value

Return ValueDescription
voidNothing is returned. The link is printed.

WordPress Examples

Three short examples. Each one shows the code and what it prints or does.

Example 1 — Print a Subscribe link

The simplest use.

WordPress
<?php
the_feed_link( 'Subscribe to posts' );

How It Works

  1. The first argument is the link text.
  2. WordPress finds the right feed URL.
  3. The default feed type is RSS 2.0.

Example 2 — Link to the Atom feed

Pass a feed type as the second argument.

WordPress
<?php
the_feed_link( 'Atom feed', 'atom' );

How It Works

  1. atom picks the Atom format.
  2. The URL changes to the Atom address.
  3. Use the one your readers prefer.

Example 3 — Get only the feed URL

If you need the URL alone, for example in the head, use the returning function.

WordPress
<?php
echo '<link rel="alternate" type="application/rss+xml" href="' . esc_url( get_feed_link() ) . '">';

How It Works

  1. get_feed_link() returns the URL without any HTML.
  2. We build our own link tag.
  3. esc_url() keeps the value safe.

Frequently Asked Questions

It prints an HTML link to your site feed, using the text you give.
rss2 (the default), atom, rdf, and rss.
Use get_feed_link(). It returns the URL, and you build the link yourself.
The function needs the visible text of the link. There is no default text.
Usually at /feed/. For example, https://example.com/feed/.

Next: the_permalink()

Print the permalink of the current post, already escaped.

the_permalink() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful