Example 1 — Print a Subscribe link
The simplest use.
<?php
the_feed_link( 'Subscribe to posts' ); How It Works
- The first argument is the link text.
- WordPress finds the right feed URL.
- The default feed type is RSS 2.0.

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.
Give the text of the link.
<?php the_feed_link( 'Subscribe to posts' ); ?> | Call | What 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().
the_feed_link( string $anchor, string $feed = '' ): void | Parameter | Description |
|---|---|
$anchor | string. The visible text of the link. It is required. |
$feed | string. The feed type: rss2, atom, rdf, or rss. Default is empty, which means the default feed. |
| Return Value | Description |
|---|---|
| void | Nothing is returned. The link is printed. |
Three short examples. Each one shows the code and what it prints or does.
The simplest use.
<?php
the_feed_link( 'Subscribe to posts' ); Pass a feed type as the second argument.
<?php
the_feed_link( 'Atom feed', 'atom' ); atom picks the Atom format.If you need the URL alone, for example in the head, use the returning function.
<?php
echo '<link rel="alternate" type="application/rss+xml" href="' . esc_url( get_feed_link() ) . '">'; get_feed_link() returns the URL without any HTML.link tag.esc_url() keeps the value safe.Print the permalink of the current post, already escaped.
6 people found this page helpful