Calculate the most recent comment for each group. Then use this to choose which group you want. You can do this calculation with a subquery:
select p.* c.*
from posts p join
comments c
on p.post_id = posts.post_id join
(select post_id, max(postdate) as postdate
from comments
group by post_id
) cmax
on cmax.post_id = p.post_id
where (case when timestampdiff(minute, now(), cmax.timestamp) <= 60
then timestampdiff(minute, now(), c.timestamp) <= 60
when timestampdiff(minute, now(), cmax.timestamp) <= 60*24
then timestampdiff(minute, now(), c.timestamp) <= 60*24
. . .
)
The syntax for the time comparison depends on whether the values are stored as timestamps or datetimes.