Three of those St. Louis officers had already been placed on desk duty by their department, and all 22 had been placed under internal investigation.

Jimmie Edwards, the St. Louis public safety director, said in an interview that he was “not prepared to say we have a cultural problem of being racist and homophobic,” but that he was upset by the posts, and that action would be taken against officers who broke the rules.

“I was embarrassed to read those posts,” Mr. Edwards said. “And I was angry. So it’s something that we have to fix.”

Heather Taylor, a St. Louis police sergeant who is president of the Ethical Society of Police, which mainly represents black officers, said the posts were saddening but not surprising. Sergeant Taylor said she saw them as more evidence of deep cultural shortcomings — in her department especially, and in American law enforcement generally.

“We weren’t shocked — this is something we’ve known forever,” Sergeant Taylor said.

She said the posts by her colleagues could further erode public trust in a department that has struggled repeatedly with scandals and protests of police shootings.

Jeff Roorda, the business manager of the St. Louis Police Officers Association, the city’s largest police union, said many of the accused officers could mount a free-speech defense in any disciplinary proceedings. He also suggested that Ms. Gardner, whose office is under investigation for its handling of a case involving a former governor, was trying to change the subject with her announcement about the exclusion list. Earlier this week, an investigator for Ms. Gardner’s office was indicted on perjury charges.

Fallout from the offensive posts has spread since they were publicized about three weeks ago by the Plain View Project. Emily Baker-White, the project’s founder, said she had been contacted by internal affairs investigators in several cities, and that an overdue conversation had started about police culture and what she called a “feedback loop of violence and machismo and discriminatory attitudes.”