Log in Sign up

Filter posts out of RSS feed based on tag?

Is there a way to not include posts with a set tag in the RSS feed?


10 months ago, 6 replies   Edit question

I do this on my RSS feed, it works the same way in any other template.

I wrap the portion in the feed with the excluded tag, i.e. apples:

{{^tagged.apples}}
  <item> 
    <title><![CDATA[ {{{title}}} ]]></title>
    <link>{{{absoluteURL}}}</link>
    <guid>{{{absoluteURL}}}</guid>
    {{! RSS feeds need a RFC 822 date}}
    <pubDate>{{#formatDate}}ddd, DD MMM YYYY HH:mm:ss ZZ{{/formatDate}}</pubDate>
    <description><![CDATA[ {{#absoluteURLs}} {{{body}}} {{/absoluteURLs}} ]]></description>
  </item>
{{/tagged.apples}}

-Ray

Answered 2 years ago · Edit answer

Would it be possible to use a version of this technique to output a feed for just one tag?

Answered 2 years ago · Edit answer

Yes! To convert a feed which ignores posts tagged apples, to a feed which only shows posts tagged apples, use the example above but replace this:

{{^tagged.apples}}

With this:

{{#tagged.apples}}

There's more about sections and inverted sections in the docs.

Answered 2 years ago · Edit answer

Thanks – much appreciated. Let the tinkering commence.

Answered 2 years ago · Edit answer

I'm using the above method to limit posts tagged with 'linkpost' in my RSS feed. I'd also like to limit posts tagged with 'meta', since those are internal site mechanics posts that I think aren't for broad consumption.

What's the proper syntax to have multiple tags in the. exclusion criteria vs. just the one?

Answered 10 months ago · Edit answer

I found the nested tag syntax in an answer to another post question.

Answered 10 months ago · Edit answer