St. Louis avoided a season sweep after losing its first five meetings with the Phillies this year.
Alec Bohm homered for Philadelphia, which leads the NL wild-card race.
Walker homered off Seranthony Domínguez (4-5) with two outs to snap a 5-all tie.
Walker also made a diving catch in right field on a sinking liner off the bat of Kyle Schwarber to begin the game.
“He's definitely on a path to be great,” Cardinals manager Oliver Marmol said. “He cares and he wants it.”
Walker flied out in his first three at-bats and came to the plate in the eighth determined to make solid contact.
“I was a little frustrated in myself,” Walker said. "I got under them and just missed. I was pulling off a little bit and went into that at-bat trying to make an adjustment. I was looking for that sinker and I'm glad I didn't miss it."
It was Walker's 16th home run and fifth game-winning RBI of the season.
John King (2-1) allowed one run in one inning for the win, and Ryan Helsley earned his 11th save in 15 opportunities.
Goldschmidt extended his on-base streak to 13 games.
“We've been playing pretty well the last few weeks,” he said. “They beat us the first couple games. It was definitely nice to find a way to win the game today.”
Marmol liked the way his team bounced back after giving up 11 runs in a pair of losses to the Phillies.
“We continue to play as if we were in the playoffs,” Marmol said.
Bohm launched a solo homer in the top of the eighth, and Nick Castellanos tied the score with an RBI single.
Goldschmidt had a two-run double in the third.
Cardinals starter Dakota Hudson, who went 4-1 in August, permitted three runs and five hits in five innings.
Philadelphia starter Taijuan Walker gave up five runs on eight hits over seven innings.
“He attacked the hitters and he gave us some length,” Phillies manager Rob Thomson said.
The series marked Philadelphia's first appearance in St. Louis since sweeping their wild-card series last year on the way to winning the National League pennant.
The Cardinals are 15-9 on Sundays this season, the only day they have a winning record.
Cardinals: OF Tyler O’Neill was placed on the 10-day injured list with a right foot sprain, and INF/OF Juan Yepez was recalled from Triple-A Memphis. Yepez is riding a 17-game hitting streak, the longest current run in the minors.
Philadelphia RHP Zack Wheeler (11-6, 3.70 ERA) is scheduled to face Braves RHP Kyle Wright (0-2, 7.48) in the opener of a three-game series Monday in Atlanta. Wheeler is 11-7 with a 3.24 ERA in 26 career starts against the Braves.
Cardinals RHP Adam Wainwright (4-11, 7.95 ERA) goes for his 200th career win when he faces Milwaukee RHP Freddy Peralta (12-8, 3.79) in the opener of a four-game series Monday in St. Louis. Wainwright is expected to retire after this season.
“When he takes the mound, you want to put forth the same effort that he's putting forward,” Goldschmidt said. “He brings the best out in everyone around him.”
AP MLB: https://apnews.com/hub/MLB