ST. LOUIS — The St. Louis Cardinals’ bats have picked a bad time to go cold.

Jon Lester pitched eight dominant innings as the Chicago Cubs beat St. Louis 7-0 on Wednesday to clinch at least a wild-card playoff berth. The Cardinals Lester gave up three hits, leaving the Cardinals with just 11 total hits while dropping two of three to the Cubs.

“We’ve got figure out ways to grind through at-bats, I think that’s one of our priorities right now, just to figure out how to get those tough-fought at-bats from top to bottom,” Cardinals manager Mike Matheny said. “That’s’ the type of team we can be and then we can jump up and surprise some people with the long ball.”

All five of the Cardinals’ runs in the series came on homers. Outfielder Brandon Moss tipped his cap to Lester.

“Today was one of those days were he had both working and he wasn’t missing over the middle and he was even throwing some curveballs and change-ups to keep you off of everything,” Moss said.

Anthony Rizzo hit a pair of home runs as the Cubs improved their MLB-best record to 93-52 and their magic number is one to clinch their first NL Central title since 2008. Chicago secured a playoff berth because St. Louis and San Francisco are the only teams that could catch them in the standings, but since those teams open a four-game series on Thursday both teams wouldn’t be able to do so.

The Cardinals began the day a half-game behind the New York Mets and a full game behind the Giants for one of the two wild-card spots.

St. Louis starter Carlos Martinez (14-8) gave up four runs and eight hits in six innings.

Martinez started off strong, striking out the side in the first and four of the first six batters he faced. Five of his nine strikeouts came on called third strikes. He entered the game having allowed just 12 homers this season and his home run per nine innings average of 0.63 was second in the National League to the Mets’ Noah Syndergaard (0.52).

“He came out of the gates really as good as we’ve seen him,” Matheny said. “Just had a real good rhythm and thought he had a real good feel for his pitches. They just kind of grinded a couple of at-bats against him and made him pay.”

Lester (17-4) allowed four base runners, none of which got past first. Cubs catcher David Ross threw out two Cardinals trying to steal second and Lester faced just two batters over the minimum.

Rizzo’s two-run homer in the ninth gave him 31 homers and 101 RBIs on the season. He is the second Cubs left-handed hitter in franchise history to post multiple 30 home run and 100 RBI seasons (Billy Williams did it in 1965, 1970 and 1972).

“Billy Williams, his numbers speak for himself and he’s done it so many years, so it’s a really good feeling,” Rizzo said.

Ross’ two-run homer in the fifth was just third by a right-handed batter against Martinez, who had his four winning decisions streak snapped.

The loss dropped the Cardinals’ home record to 33-41, assuring St. Louis of its first losing record at home since 1999 when it played in Busch Stadium II.

“We want to do well here and I think trying to right the ship here we’re putting a little too much pressure on us,” Moss said. “But when we go on the road we play a little more loose, a little more relaxed and hopefully that continues.”

TRAINERS ROOM

Cardinals: RHP Michael Wacha (right shoulder inflammation) was activated from the disabled list and will pitch out of the bullpen … OF Matt Holliday (fractured right thumb) is expected to take live batting practice later this week. . RHP Trevor Rosenthal (right shoulder inflammation) could be activated from the DL tomorrow.

UP NEXT

Cubs: LHP Mike Montgomery (1-1, 3.67 ERA) will kick off a four-game series as Chicago hosts Milwaukee on Thursday. The Brewers counter with RHP Jimmy Nelson (14-7, 4.42 ERA)

Cardinals: RHP Adam Wainwright (11-8, 4.45) will look to build on a one run, eight inning performance in his last start as St. Louis travels to San Francisco for a four-game series Thursday. RHP Johnny Cueto (15-5, 2.90) will start for the Giants.