That's a slick piece of code but fortunately this is no longer an issue for titles of paginated posts when running the Yoast plugin. The paginated pages say Page "#" of "total pages #".
Posts made by Brian-
-
RE: Pagination duplicate title and meta description