Log in Sign up

Hide specific tags from the RSS feed?

Is it possible to remove certain categories tags from the feed?


3 days ago, 3 replies   developers   rss   Edit question

Are you referring to tags? If so, then yes, for example, add the following to your template's feed.rss file to prevent all posts tagged 'apple' or 'Apple' from appearing on your feed:

...
{{^tagged.apple}}
...
{{/tagged.apple}}
...

The full result will look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
  <title><![CDATA[ {{{title}}}]]></title>
  <link>{{{blogURL}}}</link>
  <atom:link href="{{{blogURL}}}/feed.rss" rel="self" type="application/rss+xml"/>
  <description><![CDATA[ Feed for {{{title}}} ]]></description>
  {{#recentEntries}}
    {{^tagged.apple}}
  <item> 
    <title><![CDATA[ {{{title}}} ]]></title>
    <link>{{{absoluteURL}}}</link>
    <guid isPermaLink="false">{{guid}}</guid>
    {{! RSS feeds need a RFC 822 date}}
    <pubDate>{{#formatDate}}ddd, DD MMM YYYY HH:mm:ss ZZ{{/formatDate}}</pubDate>
    <dc:creator><![CDATA[ {{{blog.title}}} ]]></dc:creator>
    <description><![CDATA[ {{#encodeXML}} {{{body}}} {{/encodeXML}} ]]></description>
  </item>
    {{/tagged.apple}}
  {{/recentEntries}}
</channel>
</rss>

To understand why this works, please read the guide to Blot's templating language, specifically Inverted sections

Answered 3 days ago · Edit answer

Is it possible to stack them, like have several excluded tags?

{{#recentEntries}}
    {{^tagged.apple}}
    {{^tagged.orange}}

Lastly, is it possible to just have one tag?

{{#recentEntries}}
    {{#tagged.apple}}

I'm experimenting with this now, just wondering if you can confirm.

Thank you!

Answered 3 days ago · Edit answer

Yes you can stack them, or simply select a single one – I recommend experimenting. Please let me know if you have any questions about this or anything else

Answered 3 days ago · Edit answer