Limit NewsFeed to Display Latest 5 Posts in SharePoint 2013


I was having an issue to retrieve latest posts from newsfeed,lets say take 5 of them.Tried everything,but newsfeed webpart didnt support filtering according to my need.

So i tried a “css-trick” code i found over the internet and improved it to my needs:

function get5posts() {
var limit = 5;
$("#ms-feedthreadsdiv .ms-microfeed-thread").each(function (i) {
if (i >= limit) {

The code above shows only 5 posts on page load.But what happens if you add more in newsfeed? The 5 item limit exceeds and you need to call a function to restrict it to 5 item:

Call get5posts() in page load event:

$(document).ready(function (e) {

Afterwards call it again if user clicks on post reply button:

$("#ms-postbutton").on("click", function () {

This will limit NewsFeed to 5 posts only.

Nice Trick!


5 thoughts on “Limit NewsFeed to Display Latest 5 Posts in SharePoint 2013

    • Hi Marin,

      The only code I’ve written was a seperate Javascript file referenced via Masterpage.

      You can add NewsFeed/SiteFeed webpart to your portal,the usual way(Edit->Add WebPart)
      And then,
      the javascript code explained above shall do the rest for you.

      Hope that solves your problem.

      • If you want to use your own custom design,best approach would be a custom webpart which retrieves post from Newsfeed/SiteFeed list or retrieving posts via rest api/webservice.I’ve worked with rest api but dont know if it allows you to retrieve them.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s