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.
Following the deaths of Shangguan Yi and Shangguan Tingzhi, Shangguan Wan'er and her mother Lady Zheng—Zheng Xiuyuan's elder sister—were spared but became slaves in the inner imperial palace. As she grew older, Shangguan Wan'er showed a talent for reading widely and composing prose and poetry at an early age, along with understanding civil service regulations. Empress Wu noticed poems written by 13-year-old Shangguan Wan'er and called her to write an essay on the spot based on a given theme.