When you have failed twice to win a Triple Crown, when 12 horses have won the Kentucky Derby and Preakness but failed at the Belmont Stakes, when there hasn’t been a Triple Crown champion since Steve Cauthen rode Affirmed 37 long years ago, you pay a visit to the Ohel Chabad Lubavitz in Cambria Heights, a veritable Secretariat gallop from the track.

Victor Espinoza, who missed his shot at history a year ago with California Chrome, gets another chance Saturday on favorite American Pharoah, and if the spirit of Rebbe Menachem Mendel Schneerson proves to be a source of inspiration for him, well, a little divine intervention never hurts.

People from all walks of life visit the religious visitor center near The Rebbe’s burial site to pray for blessing, guidance and inspiration, and here was Victor Espinoza, clad in a cap and jeans, writing a prayer in Spanish and lighting a candle before ripping the paper into pieces and tossing it on the gravesite. Everywhere he went, he carried the book “Rebbe: The Life and Teachings of Menachem M. Schneerson, the Most Influential Rabbi in Modern History,” by Joseph Telushkin. He read King David’s Book of Psalms. He followed instructions to walk backwards out of respect when he left the gravesite.

“I’m not a superstitious guy,” Espinoza told The Post. “So whatever happens, if it’s meant to be, it’s meant to be. If not, then I move on like last year.”

I said to Espinoza: “A little divine intervention might not hurt, right?”

Espinoza, now outside the Anna House, where he painted with kids and signed a beautiful Susan Sommer-Luarca portrait of American Pharoah, smiled and replied: “At this point, yeah, if it helps, it helps.”

Outside Ohel Chabad, before he was driven to Anna House on the Belmont backstretch, Espinoza was asked about his written prayer.

“I think for me the most important thing is health. … Safety and health is the most important thing in life,” Espinoza said.

Why is that the most important thing for you? “Not just for me, I think for everybody. Every single human being, we need health and safety,” Espinoza said.

Perhaps he didn’t want to put so much pressure on the racing gods to actually pray outright for a Triple Crown.

“He said he was here for inspiration, and felt that he wanted to come here and say a prayer before his race,” a man involved in the visit said.

Mission accomplished.

“No matter what religion you are, or what temple you go, you always come out with a different energy,” Espinoza said, and then laughed when he added, “which is good.”

It was a blessing before the Preakness from Rabbi Sholom Ber Korf that prompted the visit Thursday by Espinoza.

“He asked for a blessing and I gave him the blessing, that he should be successful and be safe,” Rabbi Korf told The Post from Delray Beach, Fla. “It was explained to me that Victor’s the type of person that doesn’t just do it for himself, he supports various charities, Cancer For Children, so a win for him is not just a win for himself, it’s a win for all the charity causes that he supports. So I felt a blessing was in order.”

Espinoza wanted to visit The Rebbe’s gravesite when he learned about it.

“Many people who are either for reasons of personal need for health or otherwise, have come from all around the world, Jews and non-Jews alike, to be at The Rebbe’s gravesite, and ask for blessings,” Rabbi Korf said. “There’s no better place where there’s a presence of holiness, and someone who’s spiritually very well-connected to God, to ask for a blessing.”

I asked Rabbi Korf: “It’s pretty powerful having The Rebbe in your corner, right? He laughed and said: “I’d certainly want to have The Rebbe in my corner!”

Espinoza is 43 years old and a spiritual man. “I pray probably 10 times a day,” he said. “I meditate probably five, six times a day.”

The race was 53 hours away now. This has been The Week That Was for the gregarious Espinoza, who was welcomed to the big time Thursday with a Page Six item about his relationship with leggy 19-year-old blonde Kelly Kovalchick, which he insists isn’t romantic.

“She’s a friend who is a big racing fan and enjoys going to events,” Espinoza told The Post.

Espinoza enjoyed his time at Anna House, which received a $100,000 donation Thursday from American Pharoah owner Ahmed Zayat.

“I was really looking forward to come here to just hang out with the kids,” Espinoza said. “Kids are fun, they’re interesting.” He laughed. “Because they say how they feel, right?”

From the way the kids gravitated to him, it looks like they’ll be praying for a Triple Crown themselves.