How to Display WordPress Page Content as Feed

    Sumit Pore
Listen to this article

Customize Page FeedWordPress development principles, provide you a way to customize almost any feature provided by default. For instance, the feed link of a page, by default, displays the comments for that page. A client once had a different requirement, to display the page’s content in the page feed, and not the comments. The solution was quite easy to implement. We reckon, this simple trick we used, could benefit those of you, who had a similar requirement.


Let’s take an example to explain this.

Say you have a page ‘Most Visited Posts’, which lists the popular posts on your website. And let’s consider the page’s URL to be ‘’. Now, certainly this page would not have any comments. Individual posts might have comments, but not this page.

If you were to go to the feed link of that page, i.e., ‘’, then you would see nothing (because there are no comments). Therefore, people who would want to subscribe to your ‘Most Visited Posts’ via the page feed, will not see any content at that link.

[banner-full-light title=”We provide Customized Features” icon=”fontawesome-cogs”] Maybe your requirement is more complicated than customizing page feed. We assure tailor-made solutions, with a 100% satisfaction guarantee.[/banner-full-light]


Displaying the Page Content in the Page Feed

To show the content in the Page’s feed, we just made a simple change. Here’s how.

The is_feed function is called to determine if the query made is for a feed. By default, the is_comment_feed variable is set to true, thus displaying the comments as feed.

We need to change this, by setting the value for is_comment_feed to false. And in our case, since the requirement is conditional, we need to set this only for the page ‘Most Visited Posts’. You need to add the following code in the functions.php (or in a plugin if you chose so).

[pre]//hook to change the rss content for pages
add_action(‘template_redirect’, ‘wdm_show_content_in_page_feed’);

function wdm_show_content_in_page_feed() {
if(is_feed() && is_page(‘most-visited-posts’)) {
global $wp_query;
$wp_query->is_comment_feed = false;

where ‘most-visited-posts’ is the slug for your ‘Most Visited Posts’ page.

The above action is triggered on the hook ‘template_redirect‘. The action checks if the current link is a feed link or not, and if current page is ‘most-visited-posts’ page. If both these conditions are matched, it will set is_comment_feed to false.

When is_comment_feed variable is false, the content in the page will be displayed.


This was a simple enough requirement, and we were quick to provide a solution. Nevertheless, we always focus on providing the most appropriate solution for each requirement.


Sumit Pore

Sumit Pore

Leave a Reply

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

Get The Latest Updates

Subscribe to our Newsletter

A key to unlock the world of open-source. We promise not to spam your inbox.

Suggested Reads

Join our 55,000+ Subscribers

    The Wisdm Digest delivers all the latest news, and resources from the world of open-source businesses to your inbox.

    Suggested Reads