How to extract data from a SharePoint Blog and display it on the home page using the Content Query web part.
To enable the Content Query web part in Content Rollup, activate SharePoint Server Publishing Infrastructure in Site Settings > Site Collection Features.
After configuring the Content Query web part to query from the SharePoint Blog, I get only the blog title.
Note: Did not have to activate the SharePoint Server Publishing feature from Site Settings > Site Features for the Content Query web part to appear or to be used on the page.
So needed to customise ItemStyle.xsl in Site Contents > Style Library > XSL Style Sheets by adding another template with a little bit of changes. Obtained template from this site. [Link] Didn’t have to export and configure the Content_Query.webpart file to get the following done.
Note: After uploading ItemStyle.xsl, had to make sure to publish it before it would be applied.
These are the settings to push out the blog post body and published date after setting the Item style option to the added template.
And this was the code added from this link.
<xsl:template name=
"BlogPost"
match=
"Row[@Style='BlogPost']"
mode=
"itemstyle"
>
<xsl:variable name=
"SafeLinkUrl"
>
<xsl:call-template name=
"OuterTemplate.GetSafeLink"
>
<xsl:with-param name=
"UrlColumnName"
select=
"'LinkUrl'"
/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name=
"DisplayTitle"
>
<xsl:call-template name=
"OuterTemplate.GetTitle"
>
<xsl:with-param name=
"Title"
select=
"@Title"
/>
<xsl:with-param name=
"UrlColumnName"
select=
"'LinkUrl'"
/>
</xsl:call-template>
</xsl:variable>
<div class=
"custom_posttitle"
>
<xsl:call-template name=
"OuterTemplate.CallPresenceStatusIconTemplate"
/>
<a href=
"{$SafeLinkUrl}"
title=
"{@LinkToolTip}"
>
<xsl:if test=
"$ItemsHaveStreams = 'True'"
>
<xsl:attribute name=
"onclick"
>
<xsl:value-of select=
"@OnClickForWebRendering"
/>
</xsl:attribute>
</xsl:if>
<xsl:if test=
"$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'"
>
<xsl:attribute name=
"onclick"
>
<xsl:value-of disable-output-escaping=
"yes"
select=
"$OnClickTargetAttribute"
/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select=
"$DisplayTitle"
/>
</a>
</div>
<xsl:variable name=
"StartDate"
>
<xsl:value-of select=
"ddwrt:FormatDateTime(string(@PublishedDate), 1033, 'g')"
/>
</xsl:variable>
<div class=
"custom_date"
>
<xsl:value-of select=
"$StartDate"
/>
</div>
<div class=
"custom_description"
>
<xsl:value-of select=
"@Body"
disable-output-escaping=
"yes"
/>
</div>
</xsl:template>