admin管理员组

文章数量:1291013

I am trying to debug why my page feed with is returning empty.

Here's the URL for same,

http://localhost/design-patterns/code-improvement/feed/

I'm seeing the following output here,

<?xml version="1.0" encoding="UTF-8"?>
    <rss version="2.0"
    xmlns:content=".0/modules/content/"
    xmlns:dc=".1/"
    xmlns:atom=";
    xmlns:sy=".0/modules/syndication/"
    
    >
<channel>
    <title>
    Comments on: Checking Account   </title>
    <atom:link href="http://localhost/design-patterns/code-improvement/feed/" rel="self" type="application/rss+xml" />
    <link>http://localhost/design-patterns</link>
    <description>Just another WordPress site</description>
    <lastBuildDate>Mon, 26 Apr 2021 06:33:50 +0000</lastBuildDate>
    <sy:updatePeriod> hourly    </sy:updatePeriod>
    <sy:updateFrequency> 1  </sy:updateFrequency>
</channel>
</rss>

As you see there are no <item> tags present, inspite of there being content in that page.

That is because,

while ( have_comments() ) : at wp-includes\feed-rss2-comments.php

but the fact is wp-includes\feed-rss2-comments.php should never have been called, instead I needed wp-includes\feed-rss2.php which calls while ( have_posts() ) :

While debugging I reached till wp-includes\functions.php

In there the function which was getting called was do_feed_rss2. Now according to the doc if the feed is for comments the $for_commentsflag should be true.

What I observed in my case is it was giving true value and since the page had no comments the feed was returning to be empty.

So I started searching for the do_action call for do_feed_rss2 , thinking that is where the value must be getting set from, but all i could find is this,

Can anybody help me finding why is this $for_comments flag getting set as true?

Thank you.

本文标签: functionsWhy is my page feed returning empty content