Tony Watson (3-1) worked two shutout innings in relief of starter Jeff Locke. Mark Melancon pitched a perfect ninth for his fifth save. Melancon is 3 for 3 in save opportunities since All-Star closer Jason Grilli went down with a right forearm injury last week.
Matt Holliday had three hits and drove in two runs but St. Louis failed to score over the final five innings against Pittsburgh's bullpen.
"There's something we're not doing, and we know we're not doing it and fixing it," Cardinals manager Mike Matheny said.
Walker hit his seventh homer of the season off Wainwright in the first inning, starting a pattern that repeated itself throughout the night. The Cardinals found ways to score off starter Jeff Locke, but Pittsburgh kept chipping away.
"It's things we've done throughout the course of the season," Pittsburgh center fielder Andrew McCutchen said. "If we're down early, we just keep working."
The teams with the two best records in the National League were mostly spectators before Wednesday's non-waiver trade deadline, though the Pirates acquired minor leaguer Robert Andino from Seattle.
The past two seasons, the Pirates made somewhat aggressive moves meant to bolster their playoff chances, but instead contributed in part to a second-half swoon.
This time, Huntington is keeping the group he called "one of the tightest" he's been around intact. When the 4 p.m. deadline passed, the Pirates were huddled around a TV in the clubhouse. They weren't anxiously waiting for news. Instead, they were watching Martin and first baseman Garrett Jones play video games.
"The trade deadline is like a gossip magazine," Watson said. "You take it for what it's worth but it's in one ear and out the other."