making $post available inside function