President Trump frequently boasts about his love for the US military — but the feeling is not universally mutual, according to a new Military Times poll.

The survey, conducted from Oct. 23 to Dec. 2 and released this week, showed that 50 percent of troops said they had an unfavorable view of the president compared to 42 percent who had favorable views, and revealed a continued decline in his approval rating among the military since he was elected in 2016.

By comparison, a few weeks after he was elected, 46 percent of the troops surveyed had a positive view of their new commander-in-chief, compared to 37 percent who had a negative opinion.

The latest numbers still leave Trump with a higher approval rating than ex-President Barack Obama when he left office in January 2017 with a 36 percent approval rating compared to 52 percent who disapproved.

The numbers also show that Trump remains a bit more popular in the military community than among Americans as a whole.

The latest Gallup poll had the president’s disapproval rating among the public at 54 percent and his approval at 43 percent.

The Military Times poll surveyed 1,630 active-duty Military Times subscribers in partnership with the Institute for Veterans and Military Families at Syracuse University.

“These are people for whom the morals and standards of the military mean a lot,” Peter Feaver, a former White House adviser to President George W. Bush who is now a political science professor at Duke University, told the website.

“The president has criticized those same career workers in the State Department and other agencies. So, it’s possible they are more likely to be offended by the president than other parts of the military.”

Feaver said the drop in Trump’s popularity reveals growing dissatisfaction with the president and his handling of military issues.

When asked about Trump’s handling of military issues, roughly 48 percent of the troops said they had an unfavorable view of his performance, compared to 44 percent who believe he has handled that task well.

That’s a big drop from the 2018 Military Times poll, in which 59 percent said they were happy with his handling of military issues, as opposed to 20 percent who had an unfavorable view.

In the period since the 2018 poll, Trump fired his former defense secretary, retired Marine Corps Gen. Jim Mattis, ordered a controversial withdrawal of US forces from Syria, and was the subject of House impeachment hearings over the delay of military aide to Ukraine, a US ally.

“Over time, as the president has been involved with more controversial things connected to the military — whether it’s the border wall or the pardons or the way that Secretary Mattis left — that has changed the view of him,” said retired Marine Corps Col. Dave Lapan, who worked as a department spokesman during both the Obama and Trump administrations.

When asked about Trump’s decision to use military construction funds to build his long-promised border wall, 59 percent said they disapproved of his decision.

And more than half rated US relations with “traditional allies” such as NATO — which the president has criticized — as poor.

Lapan said those topics had more resonance with troops than some of the controversies early in Trump’s presidency, such as his public slams on the late Sen. John McCain, a former POW.

“His comments with McCain were upsetting to a lot of folks, but it was probably more in the senior ranks,” he told the website.

“For junior troops, Mattis is much more popular. And these other decisions affect them. So they are changing their minds more.”

Trump regularly touts increased defense spending on his watch along with better care for veterans as proof of his staunch support for the troops.