Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To show ads only in selected WordPress posts, use a block or shortcode inside each target post, an ad-management plugin with an individual-post condition, or a theme conditional that checks the post ID or slug. For strict post-only targeting, manual ad units are easier to control than AdSense Auto ads. Always test selected posts and pages where ads must not appear.
Choose the right implementation
| Method | Precision | Maintenance | Best for |
|---|---|---|---|
| Block or shortcode in each post | Exact placement in chosen posts | Higher when the list grows | A few fixed posts and editors who do not need code access |
| Ad-management plugin | Post-level conditions plus managed placements | Centralized | Sites that need reusable slots, exclusions or changing campaigns |
| Theme conditional | Exact code-level targeting | Requires developer maintenance | Custom themes and centrally controlled templates |
The available controls depend on your ad provider and WordPress setup. Plugin listings such as Advanced Ads and Ad Inserter describe post conditions, placements and insertion options; confirm the current settings in the plugin documentation before configuring production ads.
Method 1: add a block or shortcode to selected posts
Use this when only a small, stable set of posts needs an ad. Edit a target post with the block editor, place the provider’s supported ad block or your site’s ad shortcode where the slot should appear, then update the post. Repeat for each selected post.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute- Use only a block or shortcode that your ad integration supports. Arbitrary advertising JavaScript may be filtered or mishandled depending on the editor, security settings and script-loading configuration.
- Insert the slot after a paragraph, between sections or at another location that fits the page design; the insertion point is controlled individually for every post.
- Do not add the same code to a global header, sidebar or reusable site-wide block if those areas must remain ad-free.
Google’s WordPress guidance covers supported insertion approaches in Insert ad unit code into your WordPress site.
Method 2: target posts with an ad-management plugin
A plugin is usually the practical choice when placements must be managed centrally. Create an ad or placement, choose its insertion position, and set the display condition to the individual posts that should receive it. The exact labels differ by plugin and version.
- Install and configure a reputable ad-management plugin from the WordPress admin area.
- Create the ad code or shortcode supplied by your advertising provider.
- Create a placement for the desired location, such as before content, after content or a manually inserted shortcode.
- In the placement’s display or targeting rules, select the specific posts, IDs or equivalent individual-post condition.
- Review exclusions and ensure the placement is not also enabled in a global header, sidebar, archive or other site-wide location.
- Save, clear relevant caches and test both an included and excluded URL.
Because plugin behavior is configuration-dependent, verify whether a rule applies to one post, a post list, a post type or an entire template before publishing.
#1 Best Overall
Method 3: use a conditional in the single-post template
For a classic theme or a custom template, put the ad rendering call where the slot belongs and guard it with is_single():
<?php if ( is_single( array( 123, 'example-post' ) ) ) : ?>
<!-- Render the approved ad unit or site shortcode here. -->
<?php endif; ?>
Replace 123 and example-post with the target post ID or slug, and replace the comment with your site’s approved rendering method. WordPress documents is_single() as determining whether the query is for an existing single post in its function reference.
Rank #2
What the conditional matches
is_single() accepts a post ID, title, slug or an array of these values. It targets individual posts, not Pages. If the rule must include Pages or particular custom post types, use an appropriate is_singular() check instead, as explained in the Conditional Tags documentation.
Run it at the correct time
Conditional query tags work only after WordPress has prepared the query. Do not evaluate is_single() too early in functions.php; place the check in the template or in a hook that runs after the main query is available. Keep ad code in a child theme or maintained custom component so a parent-theme update does not erase it.
AdSense: manual units or Auto ads?
Manual ad units
Manual units let you choose the ad type, size and location. Add the unit only to the selected posts—through a post block, plugin placement or template conditional—when the requirement is “these posts only.” This gives the clearest boundary around where an ad can render.
Recommended Free Tools
Auto ads
Auto ads let Google choose placements on pages where it estimates they may perform well and provide a good user experience. A manual unit in a post template does not by itself disable separately enabled Auto ads elsewhere on the site. If Auto ads are active, review the current page-exclusion controls and inspect non-post pages as well as target posts. Google’s setup explanation is at Set up ads on your site.
Verify that ads appear only where intended
- Open one selected post in a logged-out or private browser session and confirm the intended slot loads.
- Open an unselected post and confirm the slot is absent.
- Check a Page, the homepage, category and tag archives, and search results.
- If a plugin is involved, inspect every active placement, including headers, sidebars, widgets and automatic insertion rules.
- If Auto ads are enabled, verify the relevant AdSense exclusions and inspect representative non-post URLs.
- Repeat the checks after changing the theme, ad plugin, cache layer or advertising-platform settings.
Policy and layout checks
Ad placement must comply with the policies that apply to your provider and page design. For AdSense, consult Ad placement policies. Keep ads distinguishable from navigation and content, avoid accidental clicks, and check mobile layouts for overlap, excessive density or cumulative layout shift.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Frequently Asked Questions
Can is_single() target a WordPress Page?
No. It targets individual posts. Use an appropriate is_singular() condition when Pages or custom post types must be included.
Rank #4
Why does an ad appear on posts I did not select?
Check for a second plugin placement, a global widget or header insertion, reusable blocks, and AdSense Auto ads. Test the page after clearing caches and review each targeting rule.
Can I show different ad blocks on different posts?
Yes. Create separate post blocks, shortcodes or plugin placements, or add separate template conditions for each post group.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

