President Donald Trump says the White House is "writing up rules and regulations" for reporters after a judge ordered the administration to restore credentials for CNN reporter Jim Acosta.

Trump told reporters Friday that "people have to behave." He added that if journalists "don't listen to the rules and regulations, we will end up back in court and we will win."

Asked what he meant by rules and regulations, Trump said: "Decorum. You can't take three questions and four questions. And just stand up and not sit down."

Trump said he wants "total freedom of the press," but added "you have to act with respect."

The White House said Friday that it would "temporarily reinstate" the credentials that were revoked after Acosta and Trump tangled during a press conference last week.

CNN had asked that Acosta's credentials be returned while a lawsuit over their revocation goes forward.

The network's chief White House correspondent has clashed repeatedly with Trump and press secretary Sarah Huckabee Sanders in briefings over the last two years. But the White House pulled his credentials last week following a combative press conference in which he clashed with Trump.

Kelly is a Trump appointee who heard arguments Wednesday from lawyers representing CNN and the Justice Department.

In a court hearing Wednesday, Justice Department lawyer James Burnham argued that Acosta deserves to lose his access over "his refusal to comply with the general standards of a press conference."

CNN's lawyer, Theodore Boutrous, argued at the hearing that Acosta is being singled out for his body of work, not his alleged rudeness.

(CBS News contributed to this report.)

CNN is suing the Trump administration, demanding that correspondent Jim Acosta's press credentials to cover the White House be returned.

The administration revoked them last week following President Trump's contentious news conference, where Acosta refused to give up a microphone when the president said he didn't want to hear anything more from him.

The lawsuit was filed Tuesday in Washington, D.C., District Court. 

Acosta is also a former correspondent for CBS Newspath. 

In a statement, the Cable News Network said in part, "The wrongful revocation of these credentials violates CNN and Jim Acosta's First Amendment rights of the press, and their Fifth Amendment rights to due process. We have asked this (DC District Court) for an immediate restraining order requiring the pass be returned to Jim, and will seek permanent relief as part of this process..." 

In response, White House Press Secretary Sarah Sanders called the lawsuit "just more grandstanding from CNN." 

"We have been advised that CNN has filed a complaint challenging the suspension of Jim Acosta's hard pass. This is just more grandstanding from CNN, and we will vigorously defend against this lawsuit," Sanders said. 

"CNN, who has nearly 50 additional hard pass holders, and Mr. Acosta is no more or less special than any other media outlet or reporter with respect to the First Amendment. After Mr. Acosta asked the president two questions—each of which the president answered—he physically refused to surrender a White House microphone to an intern, so that other reporters might ask their questions. This was not the first time this reporter has inappropriately refused to yield to other reporters.

The White House cannot run an orderly and fair press conference when a reporter acts this way, which is neither appropriate nor professional. The First Amendment is not served when a single reporter, of more than 150 present, attempts to monopolize the floor. If there is no check on this type of behavior it impedes the ability of the president, the White House staff, and members of the media to conduct business."

(The Associated Press also contributed to this report.)