Updating to handle unpublished posts properly