In a summer of scandal for the British royal family — William and Harry’s reported falling out, Meghan Markle’s diva ­antics at Wimbledon — one truly sordid royal has not been making headlines.

Prince Andrew, the Duke of York.

The Queen’s favorite son has always been useless at best, a liability at worst — boorish, piggish, entitled, greedy and often quite stupid, consorting with ­oligarchs and strongmen for ­personal profit.

But Andrew’s most dangerous entanglement — his rancid loyalty to convicted pedophile Jeffrey Epstein, which has reportedly spanned decades — has never really been challenged by the Queen, the prime minister or the British press, constrained as they are by some of the world’s most stringent libel laws.

On the heels of Epstein’s arrest last week for the sex trafficking of underage girls, the US Appeals Court for the Second Circuit has ruled that 2,000 pages from a 4-year-old defamation suit filed by one of Epstein’s and Andrew’s alleged victims, Virginia Giuffre (née Roberts), are to be unsealed.

It’s likely that names will be heavily redacted. After all, extremely rich and powerful people are contained within, including, said the court, “prominent American politicians, powerful business executives, foreign presidents, a well-known prime minister and other world leaders” — all now implicated in Epstein’s alleged sex trafficking operation.

But Prince Andrew will almost certainly be named and his behavior highly detailed. It was Giuffre, after all, who in 2011 told the Daily Mail that Epstein made her a “sex slave” when she was just 15. In 2015, The Guardian reported that, in court papers, she was forced, at age 17, to have sex with Andrew three times in three different locations. Andrew has denied these allegations.

The insolent prince would not be cowed, even as The Sunday Times UK reported that flight and public records put Roberts and Prince Andrew in three separate locations at the same time — including once on Epstein’s private Caribbean island — even as a photo surfaced of Andrew taken in 2001, his arm around then-17-year-old Virginia’s waist.

That photo was taken in Ghislaine Maxwell’s apartment. Maxwell has been named as Epstein’s longtime alleged pimp and has herself been accused of sexually abusing young girls in court rec­ords filed in New York this past April. Maxwell has denied any wrongdoing. In 2011, The Daily Telegraph reported that Epstein and Maxwell had, in 2000, been hosted at Queen Elizabeth’s Sand­ringham estate.

In fact, in 2011, after Epstein was released after serving a mere 13 months for soliciting an underage girl for prostitution — with Epstein out free on “work release” up to 12 hours a day — The Post reported that it was Prince Andrew with whom he celebrated.

The senior royal, according to the Telegraph, spent four days at the registered sex offender’s $50 million Upper East Side mansion, while Epstein worked to settle some outlandish debts plaguing Andrew’s equally greedy and parasitic ex-wife, Sarah Ferguson.

“I’m not a sexual predator,” ­Epstein told The Post back then. “I’m an ‘offender.’ It’s the difference between a murderer and a person who steals a bagel.”

Around the same time, Andrew and Epstein were photographed taking a chummy walk through Central Park, a photograph splashed in tabloids both here and in the UK.

This did not play well back home. Buckingham Palace was forced to issue a statement.

“There is a question mark over his choice of friends,” a senior royal aide told the press, “and that is quite difficult for him.”

Difficult for him?

This month, the palace was more forceful. “It is emphatically denied that the Duke of York had any form of sexual contact or relationship with Virginia Roberts,” the palace said in a statement Sunday. “Any claim to the contrary is false and without foundation.”

By the way, another witness who gave evidence in Giuffre’s case testified that Andrew spent “weeks” at Epstein’s mansion in Florida — where young women were often roaming around topless or in the pool, naked — and that the prince received “daily massages.”

Epstein’s indictment claims that when Epstein received “massages,” this led to horrors.

It’s well known that the British royal family has been fighting for survival — for popularity, for relevancy, for the continued financial backing of its subjects — since Princess Diana’s death in 1997. Modernizing the monarchy has since been a Herculean effort, and it seems the palace regards the addition of a young American woman of mixed-race heritage great progress.

But the palace and its most trusted advisers should take note: Much has happened between 2011 and today, including, for Prince Andrew, a movement that could not be more aptly named: Time’s Up.