I have added Content query webpart in home page for announcement list.

I have a done changes in XSLT file to show body field. Now I want to add attachment field.

for body i used below code:

<div class="Body">
     <xsl:value-of disable-output-escaping="yes" select="@Body" />

1 Answer 1


Try below code and see if it works for you:

<xsl:element name="SharePoint:AttachmentsField">
     <xsl:attribute name="runat">server</xsl:attribute>
     <xsl:attribute name="FieldName">Attachments</xsl:attribute>
     <xsl:attribute name="ControlMode">Display</xsl:attribute>
     <xsl:attribute name="Visible">true</xsl:attribute>
     <xsl:attribute name="ItemId">
          <xsl:value-of select="@ID"/>

Source: Attachments files on Content Query.

  • Have you tried this solution? Please Upvote(^) and accept as an Answer if it helped you. Feb 3, 2020 at 13:57
  • This code is for List view I believe. How can we add this in Content Query WebPart. If I use attachments field, it show 1 or 0 depending on the number of attachments to the list item.
    – Farhan
    Feb 10, 2020 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.