WordPress.org

Ready to get started?Download WordPress

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 insert the 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 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 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="adinserter-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='adinserter-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: 3.8.3
Last Updated: 2014-3-18
Downloads: 50,193

Ratings

4 stars
4.6 out of 5 stars

Support

2 of 4 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say 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