The funeral of Police Officer Johnny Rios on Saturday became an appeal for cops to care for themselves and each other, marking a somber end to a week that saw two NYPD officers take their own lives.

Cops in dress blues lined the streets and filled the pews of St. Margaret of Cartona R.C. Church in The Bronx, with other officers acting as pallbearers for Rios, 35, who shot himself in his home Tuesday, just weeks after proposing to his fiancée.

Father Joseph Franco said those suffering mental anguish need to seek help.

“If your elbow is broken, your foot is broken, your heart, it hurts, you go to see orthopedic doctor, you see a cardiologist or podiatrist,” Franco said. “When your brain hurts, you have to seek help. It’s an organ. It isn’t always going to be perfect.”

Rios’ commanding officer at the 50th Precinct in The Bronx, Capt. Emilio Melendez, put the onus on all cops to watch out for each other.

“Whatever was hurting Johnny is all over,” said Melendez of the seven-year veteran Rios.

“You are with God. Hopefully you have found your peace.”

“This is a tragedy. So we ask the family — and my brothers and sisters in blue — how do we bounce back from these things?

“Where there is pain, the flip side is joy. Right now you are looking at pain. Flip it. Find that joy. Please find me that joy,” Melendez said.

The captain, a 30-year military veteran, also spoke about how in a foxhole, soldiers will talk about “any and every thing.”

“Yet we are eight hours in a patrol car, eight hours at the desk next to you, right next to somebody, you can’t tell me you don’t know what’s going on in their minds and in their hearts,” Melendez said.

“So I implore you, help them out. Learn from them. Know who is in that foxhole with you. Find out what’s hurting them before they hurt themselves.

“I’m asking officers, please learn from this. Reach out to each other. Get to know each other.

“Ask for help.”

Melendez said “hopefully something good” will come out of Rios’s death, and that everyone, including families and officers, “will make changes.”

But change may not come easy, because cops fear being labeled as having problems.

“As an individual, it puts you in a situation,” said one 50th Precinct cop who asked not to be identified. “Do I ask for help? Do I get in trouble?”

The cop said more contact with department chaplains could help. “I’m in the military. The chaplains, we always see them. They were present. They talk to you,” he said. “Here, you just see them at funerals.”

Rios was the eighth NYPD officer to commit suicide this year.

The day he died, the NYPD’s chief of department called the rise in suicides among city cops this year “a contagion.”

Robert Echeverría, 56, shot himself in the head in his Queens home the next day to become the ninth officer lost.

Additional reporting by Eileen AJ Connelly