After Shangguan Yi's and Shangguan Tingzhi's deaths, Shangguan Wan'er and her mother Lady Zheng—an elder sister of the official Zheng Xiuyuan () – were spared, but became slaves in the inner imperial palace. As Shangguan Wan'er grew older, she read extensively and showed a talent for writing prose and poetry at an early age, as well as in matters of civil service regulations. After Empress Wu stumbled upon poems written by the 13-year-old Shangguan Wan'er, Empress Wu summoned Shangguan Wan'er and asked her to compose an essay based on a given theme right on the spot.
After Shangguan Yi's and Shangguan Tingzhi's deaths, Shangguan Wan'er and her mother Lady Zheng—a senior sister of the official Zheng Xiuyuan ()—were spared but became slaves in the inner imperial palace. As Shangguan Wan'er matured, she read extensively and displayed a knack for writing prose and poetry at an early age, as well as understanding civil service regulations. Upon Empress Wu discovering poems penned by 13-year-old Shangguan Wan'er, she summoned her to compose an essay on the spot based on a given theme.