Senate Majority Leader Mitch McConnell (R-Ky.), left, and House Speaker Paul D. Ryan (R-Wis.), right, listen as President Trump speaks during a meeting at the White House on Wednesday. (Evan Vucci/AP)

The top two Republicans in Congress arrived at the White House this week armed with props aimed at flattering and cajoling President Trump out of shutting down the government at the end of this month.

House Speaker Paul D. Ryan (Wis.) showed the president glossy photos of a wall under construction along the U.S.-Mexico border.

Senate Majority Leader Mitch McConnell (Ky.) brought an article from the Washington Examiner that described Trump as brilliantly handling the current budget process, and portrayed the GOP as unified and breaking through years of dysfunction.

Their message, according to two people briefed on the meeting: The budget process is going smoothly, the wall is already ­being built, and there’s no need to shut down the government. Instead, they sought to persuade Trump to put off a fight for more border wall money until after the November midterm elections, promising to try then to get him the outcome he wants, according to the people, who spoke on the condition of anonymity because they weren’t authorized to reveal details of the private discussion.

The visual aids were a subtle but deft attempt to win over a president known to prefer visual imagery over wonky typed handouts, and eager to absorb flattery at a time when the White House is enveloped in chaos.

But it could be weeks before it’s clear whether the effort was successful, as the calculated intervention came during another week when Trump showed that he was wrestling with whether to follow GOP leaders’ advice or trust his own, impulsive instincts and the demands of a restive Republican base.

One of Trump’s central campaign promises was the building of a wall along the border with Mexico, but he has been stymied by Congress in obtaining the funding he says is necessary. The current construction work is largely to replace walls and barriers that have existed for years.

Trump originally pledged that Mexico would pay for the wall, but he has recently sought U.S. taxpayer money for the project. He wants $5 billion for 2019, something few lawmakers believe is obtainable. Trump on Friday said the money could either come from Congress or he could try to redirect it from the Pentagon’s budget, adding further confusion to the planning.

The uncertainty has clouded the budget process on Capitol Hill as lawmakers work desperately to finalize spending bills to pay for government operations before current funding runs out Sept. 30 — unable to know whether their efforts will ultimately be thwarted by a Trump veto.

“You know, he does what he does,” said Rep. Dennis A. Ross (R-Fla.). “We have to take control of ourselves, and we have to put on the table for the president to sign an appropriations package and let him account for his decision.”

Since March 1, Trump has said he would happily lead the government into a partial shutdown if lawmakers don’t approve the money he wants for the wall.

Earlier this year, Trump grew furious on several mornings when he saw news coverage of a giant spending bill, which was heavily criticized by conservatives for being bloated and stuffed with liberal priorities.

“They are crushing me,” Trump told aides, referring to what conservatives on Fox News were saying about him.

So Marc Short, then the White House director of legislative affairs, brought the president a list of what the spending package did for Trump’s agenda, according to administration officials. Trump calmed down upon learning more about what was in the bill but told aides that he wanted people to be backing him up on television.

Short repeatedly told lawmakers that they needed to get people on TV if they wanted Trump to support the bill — and that it was key to him signing the legislation.

Lately, the president has made clear to top aides that he is on the fence about whether to back another spending bill. On a recent flight to Pennsylvania, Trump polled advisers about whether he should shut down the government. He asked everyone to give their opinion and seemed undecided.

Kellyanne Conway, among others, has pushed against it, White House officials said.

Complicating the process even more is the uncertain outcome of the midterm elections. If Democrats seize control of the House, it could become even more difficult for Trump to secure money for a border wall.

GOP leaders are convinced that they don’t have the votes to appropriate the money even now, when they control both chambers of Congress. They are trying to avoid a messy fight just ahead of the midterms.

Trump first seemed to agree with them Tuesday, telling the Daily Caller that he didn’t want a shutdown.

But by Wednesday, right before the meeting with Ryan and McConnell and as they sat by his side, Trump was raising the possibility of a shutdown again.

“If it happens, it happens,” he said.

After Ryan and McConnell presented Trump with the different images, however, the president changed his tune again. On Thursday, in a Fox News interview, he said a fight over the wall could wait.

“I don’t want to do anything that’s going to hurt us or potentially hurt us because I have a feeling that the Republicans are going to do very well” in the midterm elections, Trump said during the interview.

He said “most likely I will not” call for a shutdown, “but we’re going to do it immediately after the election.”

Trump spoke to Fox News in Billings, Mont., where the crowd at a rally roared its approval for a shutdown. Some congressional Republicans fear that for all the persuasion offered by GOP leaders, Trump will respond most strongly to the emotions of a base that wants to see him fight for the wall, his signature campaign promise.

Trump was given assurances at the White House meeting Wednesday that he will have GOP support for the wall funding once the midterm elections are over, said Sen. John Thune (R-S.D.).

“He is very passionate about getting a vote on and, again, getting wall funding,” said Thune, who attended the meeting. “And I think that what we’ve tried to do is convince him that the best way to do that is to fund the government, get our work done and litigate that another . . . day. . . . I felt like coming out of that meeting that everybody was in the same place.”

Thune said Republican leaders believe that shutting down the government could lead the GOP to lose a number of congressional races in “these districts that we need to win to keep the House.”

GOP leaders have found that the most effective way to influence Trump’s thinking is through constant, careful and repeated communication, working closely with Office of Management and Budget Director Mick Mulvaney, as well as trying to rapidly assemble spending bills so they aren’t forced to make last-second decisions.

Democrats, who are also eager to avoid a government shutdown, appear to be following this approach.

“If you don’t like his view on something, wait 24 hours,” said Sen. Brian Schatz (D-Hawaii), a member of the Senate Appropriations Committee. “There’s no particular reason to rely on any position he’s taken, and so the smartest thing we can do is put together bipartisan bills that have enough support in the legislative branch and put good bills on his desk.”

To show congressional leaders that he has not made up his mind about a shutdown, Trump appeared to demur again when asked about it by reporters Friday on Air Force One — while indicating that the advice he is getting from lawmakers is competing with persuasion from conservative radio and TV personalities.

“I would do it because I think it’s a great political issue,” he said. “I was reading and watching the other day, there are some people I have a lot of respect for. Rush Limbaugh says it’s the greatest thing you can do. Mark Levin, the greatest thing you can do. Your friend [Sean] Hannity, the greatest thing you can do.

“There are a lot of politicians that I like and respect and are with me all the way that would rather not do it because they have races, they’re doing well, they’re up. The way they look at it, might be good, might be bad.”