SAN FRANCISCO (AP)Wilmer Flores hit a grand slam in the first inning and matched his career high with six RBIs as the San Francisco Giants snapped out of their offensive funk and beat the St. Louis Cardinals 13-7 Saturday night to end a five-game losing streak.

On a day the Giants honored former catcher Buster Posey in a pregame ceremony, Mauricio Dubon and Darin Ruf also homered.

Additionally, San Francisco’s hitters drew eight walks, six of them scoring.

”We feel like we’ve built an offense that can see pitches and work pitchers,” Giants manager Gabe Kapler said. ”It’s the style of offense that tends to lead to big innings and big innings generally lead to wins.”

Cardinals catcher Yadier Molina reached 1,000 career RBIs. Dylan Carlson added a three-run homer, but St. Louis committed three errors and had its its three-game winning streak halted.

Logan Webb (4-1) struck out seven in five uneven innings to remain unbeaten in his last 17 starts at Oracle Park. He allowed four runs and eight hits while pitching around traffic most of the afternoon.

”You get the guys getting a lot of runs and then every inning kind of giving some back, it’s not ideal but there’s a couple things that we can take away,” Webb said. ”I have to be better than what I gave today and the last couple of outings.”

San Francisco had scored a total of five runs in its previous four games before jumping on Steven Matz (3-2) for three home runs in the first two innings.

Flores’ first grand slam since 2017 erased a 1-0 deficit and came after Matz walked two of the first three batters. Flores also had a sacrifice fly in the fourth and a bases-loaded walk in the eighth.

The Giants slugger batted with the bases loaded three times and missed a chance to become the first player in Giants history to hit two grand slams in one game.

”I should have swung,” Flores joked about his final at-bat. ”I was thinking about it, like it could be cool, but I was just staying simple. Every time I think big, nothing good happens.”

Dubon and Ruf each hit two-run drives in the second inning.

Matz was rocked by the Giants in his shortest outing of the season. The Cardinals left-hander allowed a career high-tying eight runs and five hits in three innings, raising his ERA to 7.01.

Molina’s single in the second made him the eighth primary catcher in MLB history to reach 2,000 hits and 1,000 RBIs. The last to do it was Ivan Rodriguez, who retired following the 2011 season.

POSEY’S DAY

Former Giants manager Bruce Bochy and home run king Barry Bonds were among those in attendance honoring Posey. Also on hand were former teammates Hunter Pence, Brian Wilson, Matt Cain and Bengie Molina, whose trade to the Texas Rangers in 2010 cleared the way for Posey to become San Francisco’s full-time starter behind the plate.

Molina wore a No. 28 jersey and thanked Posey for getting him a World Series ring, which the team awarded to Molina after its 2010 championship run. Molina then asked for, and received, a hug from Posey and had the five-time Silver Slugger autograph the jersey.

A lifetime .302 hitter who had 158 career home runs and 729 RBIs, Posey thanked the crowd and his former colleagues.

”I never thought this was about me,” said the 2012 NL MVP. ”This was about me being a part of something.”

Posey’s two oldest children threw out ceremonial first pitches to their father.

TRAINER’S ROOM

Cardinals: RHP Jack Flaherty (right shoulder) threw in the bullpen before the game for the first time since being shut down and going on the Injured List in spring training. . RHP Drew VerHagen was scheduled to make his second rehab appearance with Triple-A Memphis on Saturday night.

Giants: 1B Brandon Belt left in the eighth inning with neck stiffness after swinging at a pitch. Belt had come off the COVID-19 IL before the game. RHP Dominic Leone also returned from the COVID list. IF/OF Jason Vosler and RHP Sean Hjelle were optioned to Triple-A Sacramento.

UP NEXT

Cardinals RHP Dakota Hudson (2-2, 3.16) starts the series finale Sunday. Hudson has two wins in four career appearances against San Francisco. Th Giants plan to call up RHP Jakob Junis (1-0, 0.00) from the minors to make his first start of the season.

More AP MLB: https://apnews.com/tag/MLB and https://twitter.com/AP-Sports