Hello,
I’m trying to build an RSS feed that limits channel entries to a certain date range (Past 7 days ending with previous full day) and then lists them in order of view count (Post popular first, descending) and only shows 6 total.
I’ve built the RSS feed a while back, though its fairly old so maybe there’s a better way (welcome suggestions), but am a bit hung up on the PHP code for the date. Not sure what I’m doing wrong as an older version of this works.
I’ve checked my template settings and PHP is set to use and its parsing on input.
For those wondering, my ultimate goal is using Active Campaign to build a newsletter from a predefined template and using the RSS for the newsletter content and then sending on a schedule (once a week).
Here’s my code…
{exp:rss:feed channel="news"}
<?xml version="1.0" encoding="{encoding}"?>
<rss versi xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:c>
<channel>
<title>{exp:xml_encode}website.com{/exp:xml_encode}</title>
<link>http://www.website.com/</link>
<description>website Newsletter RSS Feed</description>
<dc:language>{channel_language}</dc:language>
<dc:creator>website.com</dc:creator>
<dc:rights>Copyright {gmt_date format="%Y"}</dc:rights>
<dc:date>{gmt_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
<admin:generatorAgent rdf:resource="http://expressionengine.com/" >
<?php $start_time = $this->EE->localize->decode_date('%Y-%m-%d %H:%i', $this->EE->localize->now - 561600); ?>
{exp:channel:entries channel="news" start_on="<?php echo $start_time; ?>" limit="6" rdf="off" dynamic_start="on" orderby="view_count_one"}
{exp:nsm_transplant:body}
{exp:low_replace find=" "replace="SPACE"}
<item>
<title>{title}</title>
<link>http://www.website.com/news/{url_title}</link>
<guid>{homepage}/news/{url_title}</guid>
<![CDATA[
<image>
{news_thumb}
</image>
<thumb>{news_thumb}</thumb>
]]>
<dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
</item>
{/exp:low_replace}
{/exp:nsm_transplant:body}
{/exp:channel:entries}
</channel>
</rss>
{/exp:rss:feed}Appreciate any assistance.
Thanks