WordPress.org

Plugin Directory

Ad Inserter

Insert any HTML/Javascript/PHP code into WordPress. Perfect for AdSense or contextual Amazon ads. 16 code blocks, many display options.

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

  1. After activation, click "Settings / Ad Inserter" to access the setup page.
  2. Put ad (or any other HTML/Javascript/PHP) code into the ad box.
  3. Set the display options.
  4. Save settings.

How can I replace deprecated widgets with the new one?

  1. This is needed ONLY if you have used widgets with Ad Inserter version 1.4.1 or older
  2. Locate all code blocks that are configured as widgets.
  3. Locate all widget positions (sidebars) where you have the old Ad Inserter widgets (warning message should list them).
  4. Drag new "Ad Inserter" widget to the position where there is the old, deprecated widget.
  5. Select code block for this widget to be the same as it is for the old one.
  6. Drag the old, deprecated widget to the left to remove it.
  7. Replace steps for all old widgets.

How can I disable ads on specific posts/pages?

  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.

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
  • {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.

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 I use PHP code for code block?

Enter PHP code surrounded by PHP tags. Example:

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

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 echo adinserter (3); ?>

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

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 5 amazon items related to the post tag - check above for all possible tags.

<div style="height: 531px;">
<script type="text/javascript">
var amzn_wdgt={widget:"Search"};
amzn_wdgt.tag="ad-inserter-20";
amzn_wdgt.columns="1";
amzn_wdgt.rows="5";
amzn_wdgt.defaultSearchTerm="{smart_tag}";
amzn_wdgt.searchIndex="All";
amzn_wdgt.width="300";
amzn_wdgt.showImage="True";
amzn_wdgt.showPrice="True";
amzn_wdgt.showRating="True";
amzn_wdgt.design="2";
amzn_wdgt.colorTheme="Default";
amzn_wdgt.headerTextColor="#0000AA";
amzn_wdgt.outerBackgroundColor="#FFFFFF";
amzn_wdgt.borderColor="#FFFFFF";
amzn_wdgt.marketPlace="US";
</script>
<script type="text/javascript" src="http://wms.assoc-amazon.com/20070822/US/js/AmazonWidgets.js">
</script>
</div>

Another example for nice contextual carousel below posts:

<div style="overflow: auto; width: 100%;">
<script type='text/javascript'>
var amzn_wdgt={widget:'Carousel'};
amzn_wdgt.tag='ad-inserter-20';
amzn_wdgt.widgetType='SearchAndAdd';
amzn_wdgt.searchIndex='All';
amzn_wdgt.keywords='{smart_tag}';
amzn_wdgt.title='{title}';
amzn_wdgt.width='460';
amzn_wdgt.height='250';
amzn_wdgt.marketPlace='US';
</script>
<script type='text/javascript' src='http://wms.assoc-amazon.com/20070822/US/js/swfobject_1_5.js'>
</script>
</div>

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>

Requires: 3.0 or higher
Compatible up to: 4.2.2
Last Updated: 2015-5-2
Active Installs: 10,000+

Ratings

4.9 out of 5 stars

Support

27 of 28 support threads in the last two months have been 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