Update posts.php

Tidied up the code a bit