The Kansas police officer who claimed he got a McDonald’s coffee with the words “F–ing Pig” scrawled on the cup resigned Monday after admitting the story was a hoax.

The 23-year-old cop, who wasn’t publicly identified, made the story up “as a joke,” Herington Police Chief Brian Hornaday told reporters at a news conference.

“This was completely and solely fabricated by a Herington police officer who is no longer employed with our agency,” Hornaday said.

Hornaday had originally written in a Facebook post Saturday that an employee at the Junction City McDonald’s wrote the expletive on an officer’s coffee cup, calling it a “black eye” on the community.

“This is now, absolutely, a black eye on law enforcement,” Hornaday told reporters Monday.

An investigation by Hornaday and McDonald’s found that no staffer at the fast-food eatery had written the missive. The owner of the McDonald’s had previously said that surveillance footage refuted the cop’s claims.

“In the investigation, we have found that McDonald’s and its employees did not have anything whatsoever to do with this incident,” Hornaday said.

Hornaday said the cop, who was employed by the department for two months, should have come forward before the incident became a national story.

He declined to name the cop, a former military police officer with the US Army, citing the incident as a “personnel matter.”

“It’s not a matter of us not wanting to tell you who it is, because we have no reason whatsoever to protect the former officer,” Hornaday said.

The case was brought to the Dickinson County attorney, but no criminal charges are expected, Hornaday said.

Hornaday called the incident “an obvious violation of public trust” and an example “of what not to do.”

The original public post about the hoax on Hornaday’s private Facebook page had either been deleted by Monday night or was no longer public. The Herington Police Department Facebook page also appeared to have been deleted.