[2] Because of his heritage, Wang Shi was made a scribe for the crown prince,[2][3] and he later passed, in 828, during the reign of Emperor Wenzong, a special imperial examination for those who are considered wise and righteous.
At that time, there was a major famine in the Yellow River bend area (i.e., modern northern Shaanxi and central-western Inner Mongolia), and the refugees spread throughout the region.
[2] Some time prior to 858, however, Wang Shi was no longer in an active position—rather, he was nominally the teacher for Emperor Xuānzong's son Li Men (李汶), but was holding his office at the eastern capital Luoyang.
After Wang's arrival in Annan, he built wooden defenses for the city, such that he was able to fend off Nanzhao incursions.
Later in the year, a group of soldiers, who were fearful that they would be attacked by Tang troops from Rong District (容管, headquartered in modern Yulin, Guangxi), had Wang's headquarters surrounded, demanding that he leave and return to the north, so that they could use the city to defend against a Rong District attack.
Under the recommendation of the chancellor Xiahou Zi, Emperor Yizong made Wang the governor of Zhedong to succeed Zheng.
Wang, however, justified his request by pointing out that the Yangtze River-Huai River region was the main tax base for the empire, and that a failure in suppressing Qiu's rebellion would cost the imperial government far more than the expenses of a successful campaign.
[6] In 862, the elite Yindao (銀刀, "silver sword") soldiers at Wuning Circuit (武寧, headquartered in modern Xuzhou, Jiangsu) mutinied and expelled the military governor (jiedush) Wen Zhang (溫璋).
Three days after Wang's arrival, he announced that a grand feast would be held for the Zhongwu and Yicheng troops to send them off.