Import, export, block and ads.txt
Tools around the campaigns: ready-made sets of ads for different kinds of sites, the block editor, and the ads.txt file.
Export
On the Ad campaigns list tick the campaigns you want (for example #1 and #3, or all of them with the box in the table header) and press Export selected. The browser downloads one JSON file with those campaigns: their ad code and every setting. The file contains no IDs and no statistics.
Import
Below the list, choose a file made by the export and press Import. The campaigns are added to the end of the list with new IDs and empty statistics. Your existing campaigns are not touched, so you can import the same set more than once and on any number of sites.
This is how you keep ready-made sets of ads: build a few campaigns for one kind of site (a blog, a shop, a news site), export them and import them on every new site of that kind.
What is checked
- Every value is checked like in the editor: positions, rules, numbers, dates and lists. Anything unknown is ignored.
- Execute PHP is always switched off in imported campaigns, whatever the file says, because a file that you got from somebody else could otherwise run code on your site. The notice after the import lists such campaigns. Read their code and switch Execute PHP on yourself if you trust it.
- The file must be an export file of WP Ad Inserter, up to 2 MB and 200 campaigns. Only administrators who may edit the raw ad code can import (on a multisite network: super administrators).
Block for the block editor
In the block editor add the Ad campaign block (find it by typing “ad” in the block search, group Widgets) and choose a campaign in its settings. It does the same as the [wpadinserter id="3"] shortcode. The editor shows a placeholder. The ad is chosen when the page is shown to a visitor, with all the rules of the campaign. Set the campaign’s position to Manual if the ad should appear only where you put the block.
ads.txt
The Settings page has an ads.txt box. Paste the lines that your ad networks give you, one seller per line:
google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0
The text is saved as you type and published at https://your-site/ads.txt. Lines that do not follow the format (including comments’ mistakes) are reported and are not published. Please note:
- The address is served only while there is no real
ads.txtfile in the root folder of your site. A real file is served by the web server first and wins. - Ad networks read ads.txt only at the root of the domain. If WordPress lives in a subfolder, the plugin warns you.