Jose Martinez and Tyler O'Neill homered, rookie Jack Flaherty pitched seven innings and the St. Louis Cardinals beat the Pittsburgh Pirates 5-2 Tuesday night in Mike Shildt's first game since being promoted to full-time manager.

The Cardinals have won six of seven and are 20-5 in August. Earlier in the day, St. Louis took off the interim tag on Shildt, who was put in charge after Mike Matheny was fired last month a day before the All-Star break.

St. Louis is 27-12 under Shildt. He was rewarded with a contract through 2020 after guiding the Cards back into playoff contention.

The Pirates have lost eight of 10.

Flaherty (8-6) retired his first 12 batters and gave up one run and four hits. He has allowed only 14 hits and three runs in 32 innings, walking nine and striking out 38 batters in his last five starts.

Bud Norris pitched the ninth for his 28th save in 32 opportunities.

Martinez hit a two-run homer in the first off Ivan Nova (8-8). Martinez connected for his 16th homer after Matt Carpenter reached base on an infield single.

O'Neill hit a 436-foot homer into the left field bleachers in the fourth inning for a 4-0 lead. Martinez singled ahead of O'Neil's drive.

Josh Bell scored both runs for the Pirates. He doubled in the fifth and Colin Moran hit an RBI single.

Bell drew a leadoff walk from reliever Jordan Hicks in the eighth, took third on a bloop single by Moran and scored on a double play.

Paul DeJong was hit by a pitch to start the St. Louis eighth and an apparent two-run homer by Jedd Gyorko was overturned in a crew chief review. Gyorko was given a double and he was pulled because of discomfort in his left groin. Greg Garcia's single made it 5-2.

TRAINER'S ROOM

Pirates: Josh Harrison didn't start for the second consecutive game after tweaking his left hamstring Saturday running from first to third. He walked as a pinch-hitter in the eighth and stayed in the game at second base.

Cardinals: 2B Kolten Wong was put on the 10-day disabled list with a left hamstring strain, retroactive to Aug. 26. Wong, who injured his hamstring while running out a ground ball in Saturday's game in Colorado, was batting .244 with eight home runs and 32 RBI in 110 games.

WACHA START

Starter Michael Wacha (left oblique strain) left in the third inning with a trainer at Double-A Springfield after allowing five earned runs on six hits in 2 1-3 innings Tuesday against Arkansas. He threw 52 pitches and exited because of fatigue, the Cardinals said. Wacha, who will be evaluated Wednesday, went on the disabled list June 21 and has missed 60 games.

ROSTER MOVE

With Wong going on the disabled list, the Cardinals recalled INF Patrick Wisdom from Triple-A Memphis. Wisdom, 27, is batting .288 with 15 home runs and 61 RBI in 107 games for Memphis. Wisdom was purchased from Memphis on Aug. 11 and played in nine games for the Cardinals, batting .333 (4 for 12) with a home run and three RBIs. He had played in 747 career minor league game before his major league debut.

UP NEXT

Pirates: RHP Trevor Williams (10-9, 3.44) has allowed just four runs in his last seven starts covering 42 innings. He is 2-4 with a 6.93 ERA in 10 career appearances, including seven starts against St. Louis. He is 1-2 in four starts this year.

Cardinals: RHP Miles Mikolas (13-9, 2.94) allowed a season-high 12 hits and five runs in 4 2-3 innings in last Friday's start at Colorado. He lost to the Pirates on June 1 at Busch Stadium.