Things are not going well for Donald Trump. One week after darkly hinting that “Second-Amendment people” could stop his opponent, Hillary Clinton, he now faces a seemingly insurmountable seven-point deficit in the polls. As is customary in times of trouble, Mr Trump has taken to Twitter to vent, blaming the “disgusting and corrupt media” for his slump. Were it not for their skulduggery, Mr Trump insists, he would lead by 20%.

In fact, Mr Trump arguably owes the media a debt of gratitude. Data from mediaQuant, an analytics firm, show that Mr Trump has enjoyed a healthy advantage in “earned media”, or free media coverage, throughout his campaign. Since voters tend to view advertising and “paid media” with scepticism, frequent coverage in the press can better spread a campaign’s message—without costing a penny. And Mr Trump has consistently dominated the news compared with Mrs Clinton—sometimes by margins as large as six to one. John Sides and Kalev Leetaru, two political scientists, have argued forcefully that this widespread media coverage propelled the political neophyte to the Republican nomination. They point to the striking correlation between Mr Trump’s polling percentages and share of news coverage.

Mr Trump first honed his formula for hogging the limelight in the primary campaign: create a furore by crossing a sacrosanct political line, bask in the attention for several days, then do it again before your opponents have a chance to get noticed. This strategy, which effectively starved his 16 Republican rivals of oxygen, does not work as well in a one-on-one contest: Mrs Clinton has caught up with Mr Trump in the earned-media race since wrapping up the Democratic nomination in June.

As his polling numbers drop, Mr Trump is doubling down on his media-bashing. On August 14th, his campaign threatened to blacklist the New York Times after a series of embarrassing articles, including one alleging that his campaign chairman, Paul Manafort, had received $12m in under-the-table cash from Ukraine’s ousted pro-Russian president. This seems an unlikely strategy to win votes. After decades in the spotlight, Mr Trump may at last be learning that not all publicity is good publicity.