Added null check for next/previous posts