Miguel Andujar homered for the Pirates, who had their five-game winning streak snapped. Pittsburgh was looking for its first three-game sweep in St. Louis since May 1991.
Walker gave the Cardinals a 3-1 lead with his 14th homer in the third. He also doubled and scored in the seventh.
Thompson (4-5) allowed three runs and seven hits on 92 pitches. He struck out six.
Giovanny Gallegos earned his 10th save in 16 chances.
Pittsburgh starter Johan Oviedo (8-14) lasted just 3 2/3 innings. He gave up five runs on four hits and walked a season-high six. Oviedo was coming off a two-hit shutout of Kansas City last Monday.
The Cardinals are off on Monday. It will mark the first time they have not played on Labor Day in a full season since 1993.
Cardinals: LHP Matthew Liberatore allowed three hits in three innings of a rehab outing with Triple-A Memphis. He is expected to rejoin the Cardinals after being placed on the 15-day injured list Aug. 22 with lower back tightness.
Cardinals: RHP Miles Mikolas (6-10, 4.66 ERA) pitches Tuesday in the opener of a three-game series at major league-best Atlanta. Mikolas is 1-4 with a 3.86 ERA in six career appearances against the Braves.
AP MLB: https://apnews.com/hub/mlb
Steve Overbey, The Associated Press