PHILADELPHIA — The Yankees made it clear Gerrit Cole was their top free-agent priority. With the Yankees needing to save some payroll, Didi Gregorius had to find a new home.

What a home he has found in the middle of the Phillies lineup.

Joe Girardi, Gregorius’ old manager with the Yankees and his new manager with the Phillies, said Monday that Gregorius will be in the middle of the action — not only at shortstop, but in the lineup, too — for his new team.

“Part of this depends on the [possible new] rule. If the pitchers have to face the minimum of three hitters, you think about dividing your lefties up differently,’’ Girardi said at a Citizens Bank Park press conference to introduce Gregorius and ex-Met Zack Wheeler. “Part of it depends on our young players, but it is going to be in that middle area. When I think of Didi, I think somewhere in the three, four, five area, but so much of it depends on the construction of our team when we leave spring training.’’

Gregorius, who turns 30 in February, did not fit into the Yankees’ plans with the money they were about to drop on Cole.

“[Brian] Cashman made it loud and clear that Cole was their priority,” Gregorius said.

So Gregorius knew it was time to go in another direction, and Girardi was thrilled to take his old shortstop to his new job, while the Yankees likely will move young Gleyber Torres from second to shortstop.

Gregorius came back from Tommy John surgery in 2019 and was not at his best, but he fully expects to be 100 percent healthy with the Phillies. He hit just .238 with 16 home runs and 61 RBIs in 82 games last season.

“I wasn’t at my best [in 2019] coming back from the surgery, but I showed that I can compete and the more I played, the stronger I got,’’ Gregorius said. “It was a good step and now I will play this year fully healthy and just go from there and see what I have more in store.”

Gregorius loves the passion of the Phillies fans and said he would be open to signing a long-term deal with the Phillies if things go well after he plays 2020 on a one-year, $14 million deal.

“For me, this is where I wanted to be and compete,’’ Gregorius said, noting this was the one and only offer he received.

Gregorius and Girardi have a good history; it was Girardi who improved Gregorius’ defense by teaching him how to dive on defense.

“He told me, ‘You’ve got to learn how to dive.’ I said, ‘What are you talking about?’ He said, ‘You’ve got to learn how to dive,’ because sometimes when I’d dive, I used to stop,’’ Didi explained. “He said, ‘I’m going to teach you how to dive,’ and he pulls me in his office and he says, ‘This is how you dive.’ He said, ‘You act like you’re jumping in the pool so you can just keep going.’ ”

Gregorius practiced in the pool and finally attained the liftoff Girardi wanted.

He did so much for the Yankees, and his loss could hurt them in several ways, especially in the locker room.

“I’m not going to come here and say ‘I’m the leader,’ I’m not that type of guy. If they want to talk to me, I’m always open, just the way I look at it. I’m not going to come here and step on anybody’s foot,” Gregorius said.

“My recommendation to Didi is just be yourself,’’ Girardi said. “I’m not going to ask him to go out of his way to do anything. The most important thing for me is that Didi gets comfortable and he just does his thing because when he does that, he’s special.’’