replace global $post with get_queried_object()