Pete Alonso’s second-half slump might be over.

The Mets’ first baseman homered, for a third straight game, in Wednesday’s 7-2 win over the Marlins at Citi Field, the second time he has accomplished the feat this season.

Alonso’s 37 home runs on the year are just four shy of the single-season franchise record of 41, shared by Todd Hundley and Carlos Beltran.

The record will no doubt be nice, but for the Mets to sustain their sudden resurgence, they’ll need Alonso to provide the power he has rediscovered after a brief slowdown.

“It’s a constant game of adjustments,’’ Alonso said. “This past week or so has been really good. I’ve seen a lot of the work in the cage and early work on the field start to translate [to the game] way more than it had been.”

From July 12 through the first game of Monday’s doubleheader, Alonso was uncharacteristically quiet at the plate.

Following the All-Star break and Home Run Derby, Alonso was just 12-for-77 with six extra-base hits in 96 plate appearances.

Alonso had a .650 OPS during that 22-game stretch, but still walked 16 times, which to him was no small thing.

“You’re not gonna get big hits all the time, so the best way to contribute is to pass the torch and get on base,’’ Alonso said. “I feel like I did a really good job of controlling that. Getting on base really helps.”

But not as much as homering.

His two-out, two-run shot in the first inning gave the Mets the lead, as they scored in the opening frame for a seventh consecutive game.

Despite the recent turnaround, Alonso doesn’t feel like he’s all the way back.

“It’s a consistent process,’’ Alonso said of his approach at the plate. “I’m really happy with capitalizing on a pitch today, but I got more pitches in the zone that I didn’t necessarily do much with.”

His focus in recent weeks has been on “swing efficiency’’ and tracking pitches, Alonso said.

“Just controlling my effort level at the plate and being short and compact to the baseball,’’ he said. “I’m just working on staying more consistent and continuing to help this team win.”

Hitting home runs every day will do that.