An officer said his McDonald’s coffee came with a vulgar ‘pig’ message. He made it up.

Herington Police Chief Brian Hornaday, enraged by what he described as an insult to one of his newly minted officers, wanted a viral moment.

A McDonald’s employee had written “f—ing pig” on the officer’s coffee cup, Hornaday said in a Facebook post Saturday, and when confronted, the restaurant offered a free meal to the rookie cop. “A Big Mac and large fries doesn’t make up for it,” Hornaday wrote.

“Please share!” he added.

People did, and intense controversy rippled nationwide from the small Kansas town west of Topeka, emblematic, some believed, of the idea police officers are besieged by disrespect and hatred in their communities.

The tale unraveled, bit by bit, following an investigation by McDonald’s and the department, revealing a conclusion that went viral a second time — and not in the way Hornaday first intended in his now-deleted post.

“This was completely and solely fabricated by a Herington police officer who is no longer employed by our agency,” Hornaday said at a news conference Monday, telling reporters the 23-year-old officer resigned after he “confessed” to staging the incident.

The officer, whom Hornaday did not name, was making a “joke.” But in a nod to the brush fire nature of social media that can spin a narrative out of control, the chief admonished the officer for not coming forward after the story made national news.

“We can see how something so serious can get so out of control very, very quickly,” he said. Earlier Monday, Hornaday deleted his original Facebook post, which revealed the store’s address.

The attention prompted threats to the store in nearby Junction City, he said, and advocates rallied in the officer’s defense. Law Enforcement Today, an online publication written by and for officers, said it sent care packages of coffee after it identified the officer before the ruse was revealed.

“Incidents like this are what hurts officers’ credibility, and their trust from their communities,” the site wrote in a follow-up post.

The incident mirrored an actual event at a Starbucks in Oklahoma last month, when a barista was fired after the company concluded the employee wrote “pig” on a cup for an officer.

But in this instance, the local McDonald’s dug in and reviewed video surveillance of its employees, and it “clearly shows the words were not written by one of our employees,” store owner Dana Cook told KSNT on Monday.

Hornaday praised the store’s investigative process, which mirrored his, he said.

In his deleted post, he called the original, fabricated incident a “black eye” for Junction City but conceded the embarrassment was rooted elsewhere.

“I hope [the former officer] understands the magnitude of the black eye this gives the law enforcement profession from coast to coast,” he said. “None of this can be excluded from that.”

The officer who resigned was on the force for only about two months, Hornaday said, and he joined the department after serving as an Army military police soldier.

The screening process is rigorous, with a focus on integrity, the chief said.

Herington, with a population north of 2,000, is now left with only five full-time officers, including himself, Hornaday said.

He predicted the incident would become a teachable moment at police academies.

Then he explained he was about to break bread at a McDonald’s following the news conference.

“Now if you excuse me, I’ve got a Quarter Pounder with cheese on my mind, and I’m going to go get it,” he said.