I have no doubt Trump is playing the media like a fiddle. Great example in the recent is how he criticized "The Squad" which made the Democrats come to their protection. This made the people who disagree with the Squad dislike the Dems even more, and less likely to vote for any Democrat next year.
Additionally, it also let him get more funding for the wall while people were talking about that situation, while also showing people how the Dems care more about their own image than preventing the wall.
He really is a clever guy.