iTranslated by AI
Displaying a List of News on SharePoint Online Modern Sites
Modern sites in SharePoint Online have a standard News web part, but it can only display a specified number of items. As a result, when new news is added, older news items disappear from view. While you can click See all to view every news item, it is somewhat inconvenient due to the extra step required, and it may not show up if you have hidden the title. I wanted to see if it was possible to display a list using a web part.
In conclusion, using the Document Library web part is the most suitable method for displaying an unlimited number of items.[1] Let's go ahead and add the Document Library web part to display the site pages.

It is difficult to tell which news is which using only the filename. I will create a new view named All News and configure it to display the Title column instead of the Name column.

This is almost exactly what I wanted, but there is one minor issue. Since site pages contain a mix of regular pages and news pages, I want to display only the news. You can distinguish whether a page is a news item using the Promoted State (PromotedState) column, but it is hidden by default, and you cannot configure a filter for it through the UI. Therefore, you need to use PowerShell. There are two ways to do this:
- Temporarily show the Promoted State column
- Directly modify the CAML of the view
In this article, I will introduce the latter method, which uses PnP PowerShell and allows for configuration in one go. The script is as follows:
$SITE_URL = '{{site-url}}'
$LIST_NAME = '{{list-name}}'
$VIEW_NAME = '{{view-name}}'
$CAML = @'
<Where>
<Eq>
<FieldRef Name="PromotedState" />
<Value Type="Number">2</Value>
</Eq>
</Where>
'@
Connect-PnPOnline -Url $SITE_URL -Credentials (Get-Credential)
Get-PnPView -List $LIST_NAME -Identity $VIEW_NAME | Set-PnPView -Values @{ ViewQuery = $CAML }
After executing this, you will notice that the Home page, which was previously visible, is now gone. You are now able to display a list of news items.

-
Note that the Document Library web part has a constraint where it can only display document libraries within its own site. ↩︎
Discussion