I have to get date in decrement order starting from today in each item of RSS feed. Posts in feed are coming via while loop. And when I try to get date, it only displays one value in each item. This is what I have tried
while ( $the_query->have_posts() ) {
$the_query->the_post();
$post_id = get_the_ID();
$the_post = get_post($post_id);
$excerpt = $the_post->post_excerpt;
$modified = $the_post->post_modified;
$created = $the_post->post_date;
$author_id = $the_post->post_author;
$menu_order = $the_post->menu_order;
$post_parent = $the_post->post_parent;
$author = get_the_author_meta('display_name', $author_id );
$categories = get_the_category();
switch ($csrp_pubdate_date_format) {
case "rfc":
$today = date('Y-m-d');
for($i=1; $i<=4; $i++)
{
$repeat = strtotime("-1 day",strtotime($today));
$today = date('Y-m-d',$repeat);
$pub_date = $today;
}
}//end while loop
I have used loop limit 4 just for testing purpose. It has to be infinite loop.
This is what I get
<item>
<title>
<![CDATA[
The Conundrum of Coffee – Natural Replacements
]]>
</title>
<pubDate>2019-08-05</pubDate>
</item>
<item>
<title>
<![CDATA[
The Conundrum of Coffee – Natural Replacements
]]>
<pubDate>2019-08-05</pubDate>
</item>
and so on......
This is what I require
<item>
<title>
<![CDATA[
The Conundrum of Coffee – Natural Replacements
]]>
</title>
<pubDate>2019-08-09</pubDate>
</item>
<item>
<title>
<![CDATA[
The Conundrum of Coffee – Natural Replacements
]]>
<pubDate>2019-08-08</pubDate>
</item>
<item>
<title>
<![CDATA[
The Conundrum of Coffee – Natural Replacements
]]>
</title>
<pubDate>2019-08-07</pubDate>
</item>
<item>
<title>
<![CDATA[
The Conundrum of Coffee – Natural Replacements
]]>
<pubDate>2019-08-06</pubDate>
</item>
Can someone please help me to achieve this