Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jericopulvera's avatar

How to build a news-feed for a social networking site?

  • So I want to build a news-feed system but I don't want the posts to appear based on the created_at time.
  • what are the best practices in building a newsfeed?
0 likes
3 replies
Jaytee's avatar

Well news-feeds are generally shown by the featured and/or the newest article (created_at). Same goes with such things like Twitter and Facebook, sure sometimes you may see posts from days old but mainly, it's the newly posted posts.

I suggest you stick with displaying by the created at (newest first) format. If its a newsfeed, you don't want to display them in an irrelevant order such as a name, because well that's just crap. I wouldn't want to search from A-Z looking for an article, post or whatever you want to call it and then find out, this was posted 5 years ago.

1 like
rproud's avatar
rproud
Best Answer
Level 1

There are so many different things you could possibly consider. It all depends on what you're tracking for each post.

As Jaytee said, you don't want to see irrelevant items from 5 years ago, so created at is an important component.

Next thing you can consider, if tracking, is trending posts. Things that users, either only friends of the logged in user, or of all public posts. Trending is typically determined vis clicks / views / time spent with that post in the user's view.

You then want to consider showing most relevant posts for the user. So things like topics they've written about, or interacted with.

On the relevance side, you also have people that the user interacts with the most. So for example, if they always interact with a certain users posts, then more than likely they always want to see that users posts.

Finally, advertising. If you have it.

So a news feed is quite complex, and if you want to do more than just show the user the latest posts, you'll need to track the users interactions and behaviour and write your own algorithm to determine what to show.

1 like
talhaatsix's avatar

@JAYTEE - hi , i working on social networking site . it an api in laravel . i added settings , user general settings and post settings . User general settings for posts -> public , private and friends . A single Post also have privacy settings public , private and friends .

My Question is how can i get my feeds and friends feeds with checks .

and one more thing i added share feature in post . what im doing im duplicating the post record and his attachments with share user id

Please or to participate in this conversation.