Where do you add AdSense code in a WordPress block theme?
In short: A block theme has no Widgets screen, so AdSense ad unit code goes into a Custom HTML block inside a template in the Site Editor. For Auto ads, add AdSense's site code with a header/footer code plugin. In Wiozen Theme those Custom HTML blocks sit inside ready slots marked "Advertisement"; paste the code, save, and the slot shows on the site, while empty slots take up no space at all.
Why did the place for ad code change in block themes?
In classic themes you added ad code to a sidebar under Appearance › Widgets. In a block theme every part of the page (header, post template, sidebar) is built from blocks in the Site Editor, and there is no Widgets screen. So ad code goes into the template itself, in a Custom HTML block.
AdSense gives you two kinds of code, and they go in different places:
- Ad unit code: one ad shown in one spot. Paste it into a Custom HTML block in a template.
- Site code (for Auto ads): added once to the header of every page. Use a header/footer code plugin for this; if you edit a theme file by hand, the next update wipes the change.
You can run both: with Auto ads on, fill only the ready slots you want.
Which ad slots does Wiozen Theme have?
Wiozen Theme is a free block theme with six ready ad slots:
- Leaderboard: 728 × 90 or 970 × 90. On phones the mobile banner is used instead.
- Mobile banner: 320 × 100, phones only.
- Rectangle: 300 × 250, on every screen.
- Skyscraper: 300 × 600. Stays in view while scrolling on desktop.
- In-article: 336 × 280 or 300 × 250.
- Side rails: 160 × 600 on both sides of the page, only on screens 1600 pixels wide or more.
Slots reserve their space in advance (the in-article slot is at least 280 pixels tall, for example), so text doesn't jump down when an ad loads late. A slot with no ad code isn't printed at all, so there are no gaps where you haven't filled one.
In the default News design, the post template already has two in-article slots, the sidebar has a rectangle and a skyscraper, and the front page and archive pages have side rails. You can add the other slots to any template from the block inserter under Patterns › Wiozen: Ads.
Add AdSense ad unit code step by step
- In AdSense, create a display ad unit under Ads › By ad unit and copy its code.
- In WordPress, open Appearance › Editor and pick the template where the ad should appear (the single post template, for example).
- Find the slot marked "Advertisement" and select the Custom HTML block inside it.
- Paste the code and click Save. The slot shows on the site right away.
If you've connected the site to your Wiozen account, the Appearance › Wiozen Theme › Ad slots tab lists each slot's size and the templates it sits in for the active design. Clicking a template name opens it in the Site Editor.
If you use the same ad unit in several templates, putting the code in a synced pattern (reusable block) saves work: change it in one place and it changes everywhere.
How do you put an ad on the front page?
In Wiozen Theme the front page is built from modules, so front page ads are added in the theme panel rather than the Site Editor:
- Under Appearance › Patterns, create a new synced pattern, put a Custom HTML block in it, paste your AdSense code and publish.
- Under Appearance › Wiozen Theme › Customize, add an Ad slot module to the front page modules.
- Pick the module's look (Leaderboard 728×90, Rectangle 300×250 or Flexible) and choose your pattern from the Ad block list.
Every module has "Show on desktop" and "Show on mobile" options. You can add two ad modules, one for desktop and one for phones, and show each on one kind of screen only. A module with no ad block chosen shows nothing on the site.
Turning off the "Advertisement" label and the side rails
The Ad slots tab has two settings: "Side rail ad slots" turns off the two 160 × 600 slots on very wide screens, and the "Advertisement" label setting removes the small text above filled slots. Both are on by default.
Leaving the label on is more honest with readers, and AdSense accepts labels such as "Advertisements" or "Sponsored links" next to ads.
Do you need the theme panel for this?
Not for pasting code. The ready slots are already in the templates, and the Site Editor works even if you don't connect the site to a Wiozen account; in that case the theme runs in the News design.
The Ad slots tab (the table plus the side rail and label settings), front page modules and design selection are in the theme panel. The panel opens once the site is connected to a Wiozen account with at least $5 in total top-ups; the balance stays yours and is spent in Wiozen apps. Without connecting, both settings stay at their defaults, which means on.
The consent requirement for the EEA, UK and Switzerland
Google requires sites that show AdSense ads to visitors in the European Economic Area, the UK and Switzerland to use a Google-certified consent management platform (CMP).
The cookie notice on Wiozen Theme's Settings tab is not one of those certified tools. It tells visitors about cookies and records their choice, but it doesn't stop ad code and doesn't send a consent signal to Google. If you have readers in those regions, install a separate Google-certified CMP plugin or use AdSense's own Privacy & messaging tool. The cookie notice is off by default.
Where does the ads.txt file go?
AdSense expects an ads.txt file with your publisher ID at the root of the site (yourdomain.com/ads.txt). Wiozen Theme doesn't create this file. Upload it with the line AdSense gives you to the root folder through your host's file manager, or use a plugin that does it.
Frequently asked questions
Should I add AdSense code to functions.php or header.php?
No. A block theme has no header.php, and code you write in functions.php is lost when the theme updates. Ad unit code goes in a Custom HTML block, site code in a header code plugin.
Does an empty ad slot leave a gap on the page?
No. Wiozen Theme doesn't print a slot or its label when there's no ad code in it.
Does the theme's cookie notice meet the AdSense consent requirement?
No. It isn't a Google-certified CMP. Visitors in the EEA, the UK and Switzerland need a separate certified CMP.
Can I use Auto ads together with the ready slots?
Yes. Add the site code with a header code plugin, then paste ad unit code only into the ready slots you want.
For a block theme with ad slots ready to fill, download Wiozen Theme for free and try your AdSense code in the Site Editor.