WordPress.org

Plugin Directory

Test out the new Plugin Directory and let us know what you think.

Ad Inserter

Insert any advert or HTML/Javascript/PHP code into WordPress. Perfect for all kinds of ads. 16 code blocks, many insertion options and features.

I have activated Ad Inserter. How can I use it?

  1. After activation, click "Settings / Ad Inserter" to access the settings page
  2. Put ad (or any other HTML/Javascript/PHP) code into the ad box
  3. Set automatic insertion option
  4. Enable at least one page type: Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages (some insertion options don't work on all page types)
  5. Save settings

Settings for widget

  • Nothing needed, just enter the code and save settings - widget is enabled by default
  • Go to Appearance / Widgets, drag Ad Inserter widget to the sidebar or any other widget position, select code block and click on Save

Settings for ad before the first paragraph on all posts

  • Automatic Insertion: Before Paragraph
  • On all Posts checked, other page types unchecked
  • Paragraph number: 1

Settings for ad before the last paragraph on all posts

  • Automatic Insertion: Before Paragraph
  • On all Posts checked, other page types unchecked
  • Paragraph number: 1
  • Count: From Bottom

Settings for contextual Amazon Native Shopping Ads

  • Automatic Insertion: After Content
  • On all Posts checked, other page types unchecked

Sign in to Amazon Associates, go to Widgets/Widget Source, choose ad type and set parameters. For titles and search terms use tags. For example, the code below would display amazon products related to the post tags - check documentation for all possible tags.

<script type="text/javascript">
amzn_assoc_placement = "adunit0";
amzn_assoc_search_bar = "true";
amzn_assoc_tracking_id = "ad-inserter-20";
amzn_assoc_search_bar_position = "top";
amzn_assoc_ad_mode = "search";
amzn_assoc_ad_type = "smart";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_title = "Search Results from Amazon";
amzn_assoc_default_search_phrase = "{smart_tag}";
amzn_assoc_default_category = "All";
amzn_assoc_linkid = "cf1873f027a57f63cede634cfd444bea";
</script>
<script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>

Use your own tracking id! Please note {smart_tag} as default search phrase. This makes this widget contextual.

Settings for ad before the second paragraph on all posts, but on the homepage only three ads in the first three post

  • Automatic Insertion: Before Paragraph
  • On all Posts checked, Homepage checked, other page types unchecked
  • Paragraph number: 2
  • Filter: 1, 2, 3 (in some cases 2, 4, 6 - depends on the theme and needs some testing)

Settings for ad wrapped with text of the third paragraph on all posts

  • Automatic Insertion: Before Paragraph
  • On all Posts checked, other page types unchecked
  • Block Alignment and Style: Float Left
  • Paragraph number: 3

Settings for centered ad in the middle of post paragraphs

  • Automatic Insertion: Before Paragraph
  • On all Posts checked, other page types unchecked
  • Block Alignment and Style: Center
  • Paragraph number: 0.5

Settings for ad above post excerpts on the Insurance category page

  • Automatic Insertion: Before Post
  • Category pages checked, other page types unchecked
  • Click Lists button to display lists
  • Categories: Insurance, White List checked

Settings for ad above the first and third post excerpts on the homepage

  • Automatic Insertion: Before Excerpt
  • Homepage checked, other page types unchecked
  • Filter: 1, 3

Settings for ad above the post excerpts on the Cars tag page

  • Automatic Insertion: Before Post
  • Archive pages checked, other page types unchecked
  • Click Lists button to display lists
  • Tags: Cars, White List checked

I wish to show ads side by side but not in the same block. How do I do this?

Configure block 1 and 2 with ads using:

  • Automatic Insertion: None
  • Block Alignment and Style: No Wrapping
  • Enable shortcode: checked

Configure block 3 with

[adinserter block="1"]
[adinserter block="2"]

Use block 3 to insert ads and make sure all 3 blocks are enabled for the same page types (Posts, Pages, Homepage, etc.).

= I use After Content insertion position but the code is inserted after the stuff provided by other plugins. How can I insert directly after post content?

This happens because Ad Inserter processes posts last and therefore "sees" also content added by other plugins.

Try to set Ad Inserter plugin priority to 10 (early processing, Ad Inserter settings - tab *).

How can I replace deprecated tags {adinserter n} for manual insertion with new ones [adinserter block="n"] in all posts?

Use Search Regex plugin to replace tags in all posts with few clicks. If you are not familiar with regular expressions simply use search and replace text for each code block. Use Replace to test replacements and when it works as expected use Replace & Save.

How can I add some text or title (e.g. Advertisement) above the ad?

If this is a sidebar widget then you can simply name the widget. In other cases you can add title HTML code above ad code. For example:

<h3>Advertisement</h3>

AD_CODE

Change title tag according to the theme style.

I like the plugin. How can I support it?

How can I enable/disable ads on specific posts/pages?

There are two possible approaches.

  • Approach with page/post exceptions - use this one if there are many exceptions:
  1. Go to Ad Inserter settings page and define default insertion options for post/page.
  2. Enable automatic insertion on posts/pages and choose default display: On all, On all except selected or Only on selected.
  3. Go to post/page editor and open Ad Inserter Exceptions meta box below.
  4. Check default insertion options for wanted code blocks.
  5. Set exceptions for this post or page.
  • Approach with code block settings only - use this one if there are only few exceptions:
  1. Go to Ad Inserter settings page and define default insertion options for post/page.
  2. Enable automatic insertion On all Posts/Pages.
  3. Click on Lists, enter url (or space separated urls) for Urls, e.g. /permalink-url, and white-list or black-list it.

I'm using responsive theme. How can I show or hide some ads on mobile devices?

Select device types (desktop, tablet or phone) for which you need to show ads and enable only client-side device detection.

Which device type detection should I use?

In most cases you should use ONLY client-side detection. All code blocks are generated, however, they are displayed according to settings and browser's screen width using CSS Media Queries. This works perfectly in responsive designs.

How can I disable ads for direct visitors?

Blacklist # as referer for visitors that enter web address directly into browser (no referer). Blacklist yourdomain.com as referer for visitors that browse your website yourdomain.com. To blacklist both enter yourdomain.com, #

How can I disable ads on error 404 page?

This is disabled by default. Uncheck Error 404 Page checkbox.

Is there a way to display country flag of the visitor?

Possible if you are using Ad Inserter Pro. In the header put the following code:

<link rel='stylesheet' href='/wp-content/plugins/ad-inserter/css/flags.css' type='text/css' media='all' />

In the code block use the following code for flag

<span class="flag-icon flag-icon-{country_iso2}" style="width: 400px; height: 300px;"></span>

Adjust width and height according to your needs. Please not that {country_iso2} tag works only server-side - it won't work on cached pages. Of course, you can also use static code for flags. For example, for United States:

<span class="flag-icon flag-icon-us" style="width: 400px; height: 300px;"></span>

How can I enable or disable ads on group of similar pages?

If those pages have something in common in the url (page address) then you can block them with url patterns. Use * to define url pattern to whitelist (enable) or blacklist (disable).

  1. To filter all urls starting with /url-start use /url-start*
  2. To filter all urls that contain url-pattern use *url-pattern*
  3. To filter all urls ending with url-end use *url-end

For example, to exclude ads on pages that have /shop/ in url (page address) blacklist the following url: */shop/*

WARNING: Separate urls with SPACES.

How can I put an ad in the middle of the post regardless of the number of paragraphs?

Put 0.5 as paragraph number. Value between 0 and 1 means relative position in post or page (e.g. 0.3 means paragraph 30% from top or bottom)

I'd like to rotate my ad codes based on percentage, for example show one ad 75% of the time and another one 25% of the time. Is that possible?

Yes, simply create block with 4 ads separated with |rotate|: 3 times ad1 and 1 time ad2.

How can I show different ads to different visitors according to a url query parameter?

Use Url parameters List to black/white-list certain url parameters. Leave url parameter list empty and set it to Black list to show ads for all url. You can specify either parameters or parameters with values. For example for url http://example.com?data=2&customer-id=22&device=0 you can define url parameters 'data, customer-id=22' to insert ad only for urls where there is data parameter and customer-id parameter with value 22. Separate parameters with comma.

How can I use PHP code for code block?

Enter PHP code surrounded by PHP tags and check Process PHP. Example:

<div style="width: 100%;">
Some HTML/Javascript code
</div>
<?php echo "PHP code by Ad Inserter"; ?>

How can I insert post category name into my ad code?

  1. Use {category} in the ad. This will be replaced with the post category name.
  2. You can also use
  • {title} - Title of the post
  • {short_title} - Short title (first 3 words) of the post title
  • {category} - Category of the post (or short title if there is no category)
  • {short_category} - First words before "," or "and" of the category of the post (or short title if there is no category)
  • {tag} - The first tag or general tag if the post has no tags (works only inside posts)
  • {smart_tag} - Smart selection of post tag in the following order:
    • If there is no tag then the category is used;
    • If there is a two-word tag then it is used;
    • If the first tag is a substring of the second (or vice versa) then the first tag is not taken into account
    • If the first and second tags are single words then both words are used
    • First three words of the first tag
    • General tag
  • {search_query} - Search engine query that brought visitor to your website (supports Google, Yahoo, Bing and Ask search engines), {smart_tag} is used when there is no search query. You need to disable caching to use this tag. Please note that most search queries are now encrypted.
  • {author} - Post author username (works only inside posts)
  • {author_name} Post author name (works only inside posts)

How can I rotate few versions of the same ad?

Enter them into the ad box and separate them with |rotate| (vertical bars around text rotate). Ad Inserter will insert them randomly. Example:

ad_code_1
|rotate|
ad_code_2
|rotate|
ad_code_3

How can place ads below Read More tag?

Configure ad block with the following options:

  • Automatic Insertion: After Paragraph
  • Paragraph Number: 1
  • Count only paragraphs that CONTAIN: <span id="more-

Check source code of your website for proper "read more" tag.

How can I insert code block directly into template php file?

Enable PHP function adinserter for code block and call adinserter function with code block number as parameter. Example for block 3:

<?php if (function_exists ('adinserter')) echo adinserter (3); ?>

This would generate code as defined for the code block number 3.

Center alignment does not work for some ads!

Some iframe ads can not be centered using standard approach so some additional code is needed to put them in the middle. Simply wrap ad code in a div with some style e.g. left padding. Example:

<div style="padding-left: 200px;">
ad_code
</div>

How can I rotate between different alignments so I can test an ad aligned to the right against an ad aligned to the left?

Set Block Alignment and Style to "No Wrapping" and create manual wrapping around both ads separated with |rotate|:

<div style="float: left; margin: 0 8px 8px 0;">
AD CODE LEFT
</div>

|rotate|

<div style="float: right; margin: 0 0 8px 8px;">
AD CODE RIGHT
</div>

Requires: 4.0 or higher
Compatible up to: 4.7.1
Last Updated: 2 weeks ago
Active Installs: 40,000+

Ratings

4.9 out of 5 stars

Support

35 of 35 support threads in the last two months have been marked resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says it works.
0 people say it's broken.

100,1,1 100,2,2
100,1,1 100,3,3
100,2,2
67,3,2
100,4,4
100,1,1 100,1,1 100,1,1
100,1,1
100,2,2 100,1,1
100,1,1
100,1,1
100,2,2
100,7,7
100,2,2
100,4,4
100,1,1
100,1,1
100,1,1
100,1,1 100,2,2 100,1,1 100,2,2 100,1,1
100,1,1 100,1,1
100,1,1 100,1,1 100,1,1
100,2,2
100,1,1
100,1,1
100,1,1
100,1,1
100,1,1 100,1,1 100,2,2 100,1,1
100,1,1 100,1,1 100,1,1 100,2,2
100,1,1 100,1,1
100,1,1
100,1,1 100,1,1 100,2,2
100,1,1
100,1,1
100,2,2
100,2,2 100,1,1 100,2,2
100,1,1 100,1,1
100,1,1 100,3,3 100,1,1 100,1,1 100,1,1
50,2,1
100,2,2
100,2,2 100,1,1
100,3,3 50,2,1 100,2,2 100,1,1 100,1,1
100,1,1
100,1,1 100,1,1 100,1,1 100,1,1 100,1,1 100,2,2 100,2,2 100,1,1 100,1,1
100,1,1 100,1,1 100,1,1 100,1,1
100,1,1