WordPress.org

Plugin Directory

Ad Inserter

Insert any ad or HTML/Javascript/PHP code into WordPress. Perfect for all kinds of ads. 16 code blocks, many display 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 display option
  4. Enable at least one page type: Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages (some display 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 Display: Before Paragraph
  • On all Posts checked, other page types unchecked
  • Paragraph number: 1

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

  • Automatic Display: 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 Display: 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 Display: 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 Display: 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 Display: Before Excerpt
  • Homepage checked, other page types unchecked
  • Filter: 1, 3

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

  • Automatic Display: 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 Display: None
  • Block Alignment and Style: No Wrapping
  • Enable shortcode: checked

Configure block 3 with

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

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

= I use After Content display 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 display options for post/page.
  2. Enable automatic display 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 display 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 display options for post/page.
  2. Enable automatic display 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.

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?

For example, use the following code for block 1 and enable PHP processing for this block:

<?php
if (isset ($_GET ['src'])) {
  switch ($_GET ['src']) {
    case 'email':
        echo adinserter (2);
        break;
    case 'facebook':
        echo adinserter (3);
        break;
    case 'twitter':
        echo adinserter (4);
        break;
    default:
        echo adinserter (5);
  }
} else echo adinserter (6); // no src parameter
?>

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 display 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 display: 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.

How can I create contextual Amazon ad (to show items related to the post)?

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 above for all possible tags.

Example for Amazon Native Shopping Ads (use your own tracking id):

<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>

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.6.1
Last Updated: 1 day ago
Active Installs: 30,000+

Ratings

4.9 out of 5 stars

Support

54 of 54 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