Answers.Body: <p>You can do this by filtering the Matrix field down to just the field block(s) you want using their handle.</p>
  <pre><code>{% for entry in craft.entries.section('articles').all() %}
      &lt;item&gt;
          &lt;title&gt;{{ entry.title }}&lt;/title&gt;
          &lt;link&gt;{{ entry.url }}&lt;/link&gt;
          &lt;pubDate&gt;{{ entry.postDate|rss }}&lt;/pubDate&gt;
          &lt;author&gt;{{ entry.author }}&lt;/author&gt;
          &lt;guid&gt;{{ entry.url }}&lt;/guid&gt;
          &lt;description&gt;&lt;![CDATA[
          {% for block in entry.myMatrixField.type('blockTypeHandle').all() %}
               {{ block.textContent|striptags }}
          {% endfor %}
          ]]&gt;&lt;/description&gt;
      &lt;/item&gt;
  {% endfor %}
  </code></pre>
  <p>This example filters a Matrix field down to just the blocks that have a handle of <code>blockTypeHandle</code> within the field, and outputs their content, which in this case is a rich text field with a handle of <code>textContent</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-30T13:37:18.390Z
Answers.Text: Hi Martin , your code makes sense but it doesn't work for me . My matrix field is called innerContent , my block is called innerText and my field is called text . Here is the code I used <description><![CDATA[  {% for block in entry.innerContent.type('innerText').all() %}
                                  {{ block.text|striptags }}
                                  {% endfor %}
  ]]></description>. I get a Twig error Variable "entry" does not exist. I have wrapped the code in with the right craft entries tag as the rss outputs correctly if I leave out that matrix block.
Answers.UserDisplayName: bhackett
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-31T09:31:02.307Z
Answers.Text: Hmm, that's odd. Is there an `entry` variable available within the `{% for .. in %}` loop? What do you get if you add a `{% dd entry %}` statement inside the loop?
Answers.UserDisplayName: Martin Spain
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-31T10:35:42.180Z
Answers.Text: Thanks Martin, got it working. I was using item instead of entry to define the Rss fields. Thanks for your help
Answers.UserDisplayName: bhackett
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-08-30T08:32:13.347Z
Answers.LastActivityDate: 2023-08-30T08:32:13.347Z
Answers.UserDisplayName: Martin Spain
Body: <p>I'm trying to create RSS feed for a site news section, most of it is straight forward to do but I run into an issue with the description section. That content is a sub field in a matrix field along with other subfields like downloads and block quotes.</p>
  <p>I have looked extensively, and I haven't found any examples or ideas on how to do this. I can output the matrix field itself in the rss and it gives me a list of all the fieldnames it contains but I can't find a way to output those sub fields into the RSS feed as items.
  Thanks for any help</p>
  
Tags: <matrix><rss><xml>
Title: Output matrix field content into a RSS feed
ThreadText: # Output matrix field content into a RSS feed
  
  (Asked by: username_0 on 2023-08-29)
  
  I'm trying to create RSS feed for a site news section, most of it is straight forward to do but I run into an issue with the description section. That content is a sub field in a matrix field along with other subfields like downloads and block quotes.
  
  I have looked extensively, and I haven't found any examples or ideas on how to do this. I can output the matrix field itself in the rss and it gives me a list of all the fieldnames it contains but I can't find a way to output those sub fields into the RSS feed as items.
  Thanks for any help
  
  **Tags:** matrix, rss, xml
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-08-30. Score: 1 | Accepted answer
  
  You can do this by filtering the Matrix field down to just the field block(s) you want using their handle.
  
  ```
  {% for entry in craft.entries.section('articles').all() %}
      <item>
          <title>{{ entry.title }}</title>
          <link>{{ entry.url }}</link>
          <pubDate>{{ entry.postDate|rss }}</pubDate>
          <author>{{ entry.author }}</author>
          <guid>{{ entry.url }}</guid>
          <description><![CDATA[
          {% for block in entry.myMatrixField.type('blockTypeHandle').all() %}
               {{ block.textContent|striptags }}
          {% endfor %}
          ]]></description>
      </item>
  {% endfor %}
  
  ```
  
  This example filters a Matrix field down to just the blocks that have a handle of `blockTypeHandle` within the field, and outputs their content, which in this case is a rich text field with a handle of `textContent`.
  
  > **Comments:**
  > **username_0**: Hi username_1 , your code makes sense but it doesn't work for me . My matrix field is called innerContent , my block is called innerText and my field is called text . Here is the code I used <description><![CDATA[  {% for block in entry.innerContent.type('innerText').all() %}                                 {{ block.text|striptags }}                                 {% endfor %} ]]></description>. I get a Twig error Variable "entry" does not exist. I have wrapped the code in with the right craft entries tag as the rss outputs correctly if I leave out that matrix block.  
  > **username_1**: Hmm, that's odd. Is there an `entry` variable available within the `{% for .. in %}` loop? What do you get if you add a `{% dd entry %}` statement inside the loop?  
  > **username_0**: Thanks username_1, got it working. I was using item instead of entry to define the Rss fields. Thanks for your help  
  
  ---
  
  