I’m not really sure if your tables are in sql, but in case they are, I think the best way to get the data as you want is with a LEFT JOIN as follows:
SELECT * FROM follow
JOIN posts
ON (follow.friends = posts.uid OR follow.uid = posts.uid)
WHERE follow.uid = {user_uid}
Where {user_id} is the user id you want.
If this is the case, please take a further look to joins (f.e. at tizag) and left joins.
2
solved get the follow posts based on date [closed]