Fix incorrect post_path link generation

Porting the fixes from 757e985 and 404c1a3.