Mar 19
SharePoint – Blog post filtering based on category stop working

This issue applies to SharePoint 2013 and SharePoint Online 2013 as well.

If you are running blogs on SharePoint 2013 platforms, you may face the following issue when trying to filter blog posts based on category by hitting the category link shown on the Quick Launch or the category associated to the post. Doing so returns ALL posts what ever the category you asked to display (as shown below).

image 

Repro Steps

To reproduce the issue, just to the following:

  • Go to the Posts list settings to enable Content Approval
  • Then disable the Content Approval

This has been confirmed and escalated for resolution. It appears this is because the XML query is being modified by removing the category filtering.

However, in the mean time, here is a workaround.

Workaround

  • Create a blog site and do not enable the Content Approval
  • Using SharePoint Designer open the new blog site and browse to All files\Lists\Categories and edit the category.aspx page

image 

  • Open your faulty blog site and do the same (edit the category.aspx page)
  • Locate the following code (NOTE: the GUID is the specific one to your environment)

<View Name="{F28F9AA8-7F35-4912-BAF5-1A225F33B484}" Type="HTML" Hidden="TRUE" ReadOnly="TRUE" FreeForm="TRUE" ModerationType="HideUnapproved" DisplayName="" Url="/Lists/Categories/Category.aspx" Level="1" BaseViewID="8" ContentTypeID="0x" ><Query><OrderBy><FieldRef Name="PublishedDate" Ascending="FALSE"/><FieldRef Name="ID" Ascending="FALSE"/></OrderBy></Query><ViewFields><FieldRef Name="Title"/><FieldRef Name="Body"/><FieldRef Name="Author"/><FieldRef Name="PostedByWithDate"/><FieldRef Name="CategoryWithLink"/><FieldRef Name="Permalink"/><FieldRef Name="EmailPostLink"/><FieldRef Name="NumCommentsWithLink"/><FieldRef Name="PublishedDate"/><FieldRef Name="PostCategory"/><FieldRef Name="AverageRating"/><FieldRef Name="RatedBy" Explicit="TRUE"/><FieldRef Name="Ratings" Explicit="TRUE"/></ViewFields><RowLimit Paged="TRUE">10</RowLimit><JSLink>sp.ui.blogs.js</JSLink><XslLink>blog.xsl</XslLink><Toolbar Type="None"/></View>

  • Add the following code after the </OrderBy> and before the </Query> tags

<Where><And><And><In><FieldRef Name="PostCategory" LookupId="TRUE"/><Values><Value Type="Integer"><IfEqual><Expr1><GetVar Scope="Request" Name="CategoryId"/></Expr1><Expr2/><Then>-1</Then><Else><GetVar Scope="Request" Name="CategoryId"/></Else></IfEqual></Value></Values></In><Leq><FieldRef Name="PublishedDate"/><Value Type="DateTime"><Today/></Value></Leq></And><Eq><FieldRef Name="_ModerationStatus"/><Value Type="ModStat">0</Value></Eq></And></Where>

  • which then looks like

<View Name="{F28F9AA8-7F35-4912-BAF5-1A225F33B484}" Type="HTML" Hidden="TRUE" ReadOnly="TRUE" FreeForm="TRUE" ModerationType="HideUnapproved" DisplayName="" Url="/Lists/Categories/Category.aspx" Level="1" BaseViewID="8" ContentTypeID="0x" ><Query><OrderBy><FieldRef Name="PublishedDate" Ascending="FALSE"/><FieldRef Name="ID" Ascending="FALSE"/></OrderBy><Where><And><And><In><FieldRef Name="PostCategory" LookupId="TRUE"/><Values><Value Type="Integer"><IfEqual><Expr1><GetVar Scope="Request" Name="CategoryId"/></Expr1><Expr2/><Then>-1</Then><Else><GetVar Scope="Request" Name="CategoryId"/></Else></IfEqual></Value></Values></In><Leq><FieldRef Name="PublishedDate"/><Value Type="DateTime"><Today/></Value></Leq></And><Eq><FieldRef Name="_ModerationStatus"/><Value Type="ModStat">0</Value></Eq></And></Where></Query><ViewFields><FieldRef Name="Title"/><FieldRef Name="Body"/><FieldRef Name="Author"/><FieldRef Name="PostedByWithDate"/><FieldRef Name="CategoryWithLink"/><FieldRef Name="Permalink"/><FieldRef Name="EmailPostLink"/><FieldRef Name="NumCommentsWithLink"/><FieldRef Name="PublishedDate"/><FieldRef Name="PostCategory"/><FieldRef Name="AverageRating"/><FieldRef Name="RatedBy" Explicit="TRUE"/><FieldRef Name="Ratings" Explicit="TRUE"/></ViewFields><RowLimit Paged="TRUE">10</RowLimit><JSLink>sp.ui.blogs.js</JSLink><XslLink>blog.xsl</XslLink><Toolbar Type="None"/></View>

  • Save the page, et voilà the category filtering is working again

To finalize the operation, open the category.aspx page with your web browser to remove the Blog Tools webpart which will be in error and add it again.

image 

​Privacy Information

This blog is using tracking code for analytics purpose.

No personal data are stored and maintained.

 Copyright

 Follow Me On

 Share This

 Translation Tool

Translate this page