HCWP CAML Query - How to order by popularity/views/likes?

New Contributor

I have a SharePoint site with numerous Site Pages that contain guides for using our IT systems. On the Home Page, I'm trying to automatically organize them using Highlighted Content Web Parts. The site page library has a multi-choice column I use to filter the HCWP.


The issue I have is I want the HCWP to only show the most popular pages in each filtered category.


The filter I have works fine, but I can't figure out what property to use for the OrderBy. None of them seem to do anything. If I use the "Title" property it works as expected, so the code should be fine, the problem is what property to use for ordering by popularity? I'm not picky on how to define popularity, whether it's number of likes or views or something else. I've tried LikesCount, ows_LikesCount, ViewsLast1Days, ViewsRecent, and ViewsLifeTime. These are all managed or crawled properties. I don't know if they're actually being used by the site pages. The "Like count" column in the Site Pages library does update correctly, but I have no idea if that's related to the LikesCount managed property.



<FieldRef Name="LikesCount" Ascending="FALSE" />

<FieldRef Name="ITKnowledgebase" />
<Value Type="Choice">SharePoint</Value>
<FieldRef Name="ITKnowledgebase" />
<Value Type="Choice">OneDrive</Value>



0 Replies