I will give you some pseudo sql just to show the idea I would use, you can add the missing bits and get it working. It assumes that the top 5% is based in the number of posts, but if it was based in the score of likes plus views, should be trivial to adjust.
SET @foo=0.05 * select count(*) from posts where (timestamp < today - 24 hours);
PREPARE STMT FROM 'SELECT posts,sum(likes) * 2 + sum(views) as POPULAR FROM (tables joined) ORDER BY popular LIMIT ?';
EXECUTE STMT USING @foo;
Regards,