Forum Discussion
CAML/KQL Filter for Highlighted Content Modern Web Part
AndrewWDC this is going to depend on whether you want to pull pages from multiple sites or just the same site the highlight content web part page exists in. If it's the former, you need a KQL query. If it's the latter, it'll be a CAML query. You'll also need to index the site column and find its corresponding Managed Property in your search settings.
Assuming you're looking in multiple sites, here's a KQL query that will get you all site pages:
ContentType:Site Page
now let's say you add a choice column named "PageType" and have two choices, "highlight" and "normal". First, it needs to be indexed. Then you need to go to your Search settings and look at Managed Properties. Search for your column name. In my case, the managed property is ows_q_CHCS_PageType. So my query can now be modified as follows:
ContentType:Site Page AND ows_q_CHCS_PageType:highlight
This will show me all Site Pages in all site collections that have had the PageType set to "highlight".
Hope this helps.