Added a condition to check if the post its published in the sync function