WordPress.org

Plugin Directory

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

Ad Inserter

Insert any advert or code into WordPress. Perfect for all kinds of banners and ads including AdSense and Amazon. Powerful features, simple use.

Using The WordPress Dashboard

  1. Go to WordPress Plugins menu, click Add New button
  2. Search for ad inserter
  3. Click 'Install Now'
  4. Activate Ad Inserter on the Plugin dashboard

Uploading plugin file

  1. Go to WordPress Plugins menu, click Add New button
  2. Click Upload Plugin
  3. Select ad-inserter.zip from your computer
  4. Click 'Install Now'
  5. Activate Ad Inserter in the Plugin dashboard

Using FTP

  1. Download ad-inserter.zip
  2. Extract ad-inserter directory to your computer
  3. Upload ad-inserter directory to the /wp-content/plugins/ directory
  4. Activate Ad Inserter in the Plugin dashboard

Ad Inserter Pro Installation

If you are using free Ad Inserter simply uninstall it. The Pro version will automatically import existing settings from the free version. After you receive the email with download link for the Ad Inserter Pro plugin, download it, go to WordPress Plugins, Add New, Upload Plugin, Choose file, click on Install Now, activate it and then click "Enter License Key" and enter license key you got in the email.

Uploading plugin file

  1. Go to WordPress Plugins menu, click Add New button
  2. Click Upload Plugin
  3. Select ad-inserter-pro.zip from your computer
  4. Click 'Install Now'
  5. Activate Ad Inserter Pro in the Plugin dashboard

Using FTP

  1. Download ad-inserter-pro.zip
  2. Extract ad-inserter-pro directory to your computer
  3. Upload ad-inserter-pro directory to the /wp-content/plugins/ directory
  4. Activate Ad Inserter Pro in the Plugin dashboard

Uninstall

If you deactivate and delete Ad Inserter, the settings will stay in the database. To completely remove the plugin and settings do the following:

  1. Go to Ad Inserter Settings (tab *) and click on Reset All Settings
  2. Deactivate Ad Inserter
  3. Delete Ad Inserter plugin

Quick Start

Few very important things you need to know in order to insert code and display some ad:

  • Code block is any code (for example AdSense ad) that has to be inserted (and displayed) at some position. Each code block can be configured to insert code at almost any position supported by WordPress
  • Enable and use at least one insertion option (Automatic insertion, Widget, Shortcode, PHP function call)
  • Enable insertion on at least one WordPress page type (Posts, Static pages, Homepage, Category pages, Search Pages, Archive pages)
  • For Posts and static pages select default value On all Posts / On all Static pages unless you really know what are you doing
  • If you don't see inserted code block turn on debugging functions: Label inserted blocks, Show available positions for automatic insertion (Ad Inserter menu item in the WordPress toolbar on the top of every post/page)

Few typical settings are described on the FAQ page. Please make sure you have also read WARNINGS on the bottom of this page and instructions for Debugging.

Settings

Each code block has a name and settings which are divided into sections. Some settings depend also on automatic insertion used. To rename code block click on the block name. Check Simple editor to switch to simple editor for mobile devices. If you have PHP code (surrounded with PHP tags ) in code block, you need to check Process PHP to enable PHP processing. When you are finished with settings you need to save them by clicking on the button Save Settings.

Each code block has 4 insertion options:

  • Automatic Insertion
  • Widget
  • Shortcode
  • PHP function call

Normally for each code block you use only one insertion option. Of course, you can use all 4 options simultaneously taking into account that all insertion options use the same block settings (with some exceptions mentioned below).

To insert code block and display ad at some position you need to enable and use at least one insertion option.

Automatic Insertion Options:

  • Insert Before Post (before post or posts on blog pages, previously named Before Title)
  • Insert Before Content (before post or static page text)
  • Insert Before Paragraph (on posts, static pages and blog pages)
  • Insert After Paragraph (on posts, static pages and blog pages)
  • Insert After Content (after post or static page text)
  • Insert After Post (after post or posts on blog pages)
  • Insert Before Excerpt (on blog pages)
  • Insert After Excerpt (on blog pages)
  • Insert Between Posts (on blog pages)

For single posts or static pages insertion position Before Post usually means position above the post/page title, for blog pages Before Post position means position above all the posts on the blog page.

For single posts or static pages insertion position After Post means position below the post/page after all the content, for blog pages After Post position means position below all the posts on the blog page.

Please use Show positions function to see available positions for automatic insertion (Ad Inserter menu item in the WordPress toolbar on the top of every post/page).

Block Alignment and Style:

  • No Wrapping (leaves ad code as it is, otherwise it is wrapped by a div)
  • Custom CSS (You can enter custom CSS code for wrapping div)
  • Default (simple div with thin margin)
  • Align Left
  • Align Right
  • Center
  • Float Left (ad on left with wrapped text on right)
  • Float Right (ad on right with wrapped text on left)

[ Preview ]

Ad Inserter has a very useful function that can help you to check if the ad code is working and to see how it will look like when it will be inserted. Click on the Preview button to open Preview window. WARNING: Some adblockers may block code on the Ad Inserter preview window. If you see warning PAGE BLOCKED or you don't see your code and the widow elements are distorted, make sure you have disabled ad blockers. On the top of the window there is visual CSS editor and four buttons and below there is CSS code of the wrapping div (which can be edited manually) and 'Block Alignment and Style' selection.

Below the settings there is a preview of the saved code between two dummy paragraphs. Here you can test various block alignments, visually edit margin and padding values of the wrapping div or write CSS code directly and watch live preview. Highlight button highlights background, wrapping div margin and code area, while Reset button restores all the values to those of the current block. You can resize the window (and refresh the page to reload ads) to check display with different screen widths. Once you are satisfied with alignment click on the Use button and the settings will be copied to the active block.

Please note that the code displayed here is the code that is saved for this block, while block name, alignment and style are taken from the current block settings (may not be saved). No Wrapping style inserts the code as it is so margin and padding can't be set. However, you can use own HTML code for the block.

Please note that Preview window uses also Header and Footer code.

Check screenshots for explanation on alignment.

CACHING

Keep in mind that just installing a caching plugin does not necessarily make your site faster. Doing a bit of optimization will get you a lot of speed increase without caching plugins. To further combat slowness you may want to re-evaluate the performance of your hosting package. Maybe you've outgrown it. In that case, upgrade to a better hosting solution.

Caching on the frontend side (what visitors see) in some cases does speed up page loading but may also cause some unwanted behavior. When you are using caching and visitor visits some page, WordPress creates that page, Ad Inseter is called to do the job, the created page is sent to the visitor and it is also saved for quicker serving later. The next time the page is visited the visitor gets cached (saved) page. Because of this some Ad Inserter functions can not work because Ad Inserter is not called when the page is cached:

  • Server-side block rotation with |rotate|
  • User check
  • Server-side device detection
  • Referer check
  • Server-side GEO targeting (country detection, Pro only)
  • Server-side IP address detection (Pro only)
  • Debugging functions

When you need the functions listed above you have to switch off caching (if possible only on selected pages where needed).

However, Ad Inserter also supports some of the functions above even when caching is enabled:

  • Client-side ad rotation with |rotate|
  • Client-side device detection
  • Client-side GEO targeting (country detection, Pro only)
  • Client-side IP address detection (Pro only)

All you have to do is to set enable and use client-side functions (executed in the visitor's browser). But you have to be careful as some adverts might not work properly or can't be used this way and you might violate their Terms of Service.

PLEASE NOTE: If you are using W3 Total Cache for caching then you can still use server-side ad rotation, IP address and country detection even when the pages are cached as Ad Inserter supports special features of this caching plugin.

W3 Total Cache

If you are using W3 Total Cache for caching then you can still use server-side ad rotation, IP address and country detection even when the pages are cached as Ad Inserter supports special features of this caching plugin. To enable this mode go to Ad Inserter plugin settings tab * / tab General and set Dynamic blocks to Server-side with W3 Total Cache and configure W3 Total Cache for dynamic content.

When Dynamic blocks is set to Server-side with W3 Total Cache and you are using ad rotation, IP address or country detection, Ad Inserter inserts short PHP code with special tags in place of code block. When W3 Total Cache plugin loads cached page it executes this code before it serves the pages. So the page is stills served from the cache but the Ad Inserter blocks are dynamically created just before the page is served. Therefore, pages are served from the cache and the Ad Inserter code is still generated on the server-side.

Configure W3 Total Cache

How to fully set up W3 Total Cache is beyond the scope of this page. Check the W3 Total Cache manuals or contact it's developer for help with that if you need it.

  • In General Settings set the Page Caching to Disk: Basic.
  • In Page Cache under Advanced enable Late Initialization.
  • If you use the Minify option add mfunc to the ignored comment stem field.

You need to flush the cache after making these changes.

Please note also the following:

  • Mixing static cached and dynamic content is a tricky thing to do and often causes all kinds of issues. Ad Inserter follows the guidelines from W3 Total Cache on this. If it doesn't work it's very likely you didn't configure W3 Total Cache correctly. Alternatively, you can decide to use client-side option for dynamic blocks - your adverts will show up just fine and rotation and GEO targeting will still work.
  • In order to use dynamic content with W3 Total Cache, W3TC_DYNAMIC_SECURITY PHP constant needs to be defined. Usually it is located in the wp-confing.php file. This is a security string used when generating PHP code for dynamic content. If this constant is not defined, Ad Inserter will define and use it.
  • Do not use debugging functions when caching is activated.
  • When you make changes in settings of the W3 Total Cache purge all caches before you check page.
  • After you activate W3 Total Cache plugin go to General Settings and Save all settings.

Ad rotation

To use client-side rotation you have to enable it first. Go to Ad Inserter plugin settings tab * / tab General and set Dynamic blocks to Client-side.

Configure blocks normally and separate different versions with |rotate| tag. When the page will be created and Ad Inserter called, it will generate hidden code for all block versions. When the page will be loaded in the browser, one randomly chosen version of the code will be displayed. For example, to rotate 3 images:

<img style='height: 400px;' src="http://malsup.github.io/images/p1.jpg">
|rotate|
<img style='height: 400px;' src="http://malsup.github.io/images/p2.jpg">
|rotate|
<img style='height: 400px;' src="http://malsup.github.io/images/p3.jpg">

Please note the following:

  • Client-side rotation works fine with banners, text ads and many ad networks including Amazon Associates. However, it should not be used with some ad networks including AdSense (hiding ad units is not allowed) because of the method used for client-side rotation: all options are present on the page but are hidden until the page is loaded and one option is made visible. Please check Terms of Service for your ad network.
  • Ad Inserter reserves space for code block based on the height of the first block version. If all the versions have the same height then you won't notice anything. However, if block versions have different heights then it makes sense to define fixed block height with Custom CSS to avoid content jumping when block option with different or initially unknown height is displayed. If the first option is some Javascript based ad (e.g. Amazon widget) you should wrap it with a div and define height, for example <div style="height: 300px;"> ... </div>
  • Since the code (block option) is displayed only when the page is loaded, you may notice a very short delay (few 100 ms) before the code (or ad) is displayed.
  • Client-side rotation uses div elements to wrap the code(s). This is not important unless you use No wrapping style.

WARNING: If you are using caching, the inserted code may not appear immediately on the page. Make sure you disable caching when you are testing or debugging. Some caching plugins like WP Super Cache and W3 Total Cache have an option to disable caching for known (logged in) users.

DEBUGGING

Ad Inserter has many debugging functions that can help you to diagnose the problem when you don't see your ads at expected positions.

  • Code preview: click on the Preview button for each code block to see how the ad or code will look like. On the Preview window click on the Highlight button to highlight code. If you don't see the ad displayed here it is very likely that the code is not working properly.
  • Debugger Widget: Place Debugger widget in some widget area to see basic WordPress page and Ad Inserter data (User status, Page Type, Post ID, Url, Referer, etc). With this widget you can also check saved block settings and client-side viewport name.
  • Debugger Shortcode: Place shortcode [adinserter block="0"] or [adinserter name="Debugger"] into post or static page to see basic WordPress page and Ad Inserter data

Each post/page has a WordPress toolbar on the top. Ad Inserter menu (visible only to administrators and can be hidden) item has the following debugging functions:

  • Label Blocks: Each inserted block is labeled with a thin red border and red bar with block number, name and counters. Blocks that use client-side detection and are hidden are shown with blue bar and viewport name - resize the browser to check display for other devices (or screen widths). If you see only red bar then this means that the block with your code is inserted but the code doesn't display anything.
  • Show Positions: Enable this function to show available positions for automatic insertion. Displayed positions are based on the theme layout and configured paragraph counting. You can choose between all paragraph tag lists (or counting parameters) used for blocks configured for Before or After paragraph. If you click on the Show Positions menu item you'll see default paragraph positions for p tags.
  • Show HTML tags: Enable this function to see HTML tags used in the post. Use this function to determine post structure in order to configure paragraph counting.
  • Disable insertion: Use this function to temporarily disable insertion of code blocks - everything else on the page will look like the code blocks were processed and inserted.
  • Log Processing: Use this function to log insertion process in order to determine why some code block was not inserted. The log is added as HTML comment at the end of the page - check page source

WARNING: Make sure caching is disabled while debugging! All debugging functions you enable will be visible only to you!

When browsing other pages on the website debugging settings are temporarily saved (in a cookie). To disable all debugging functions click on the 'Ad Inserter' top menu item in the toolbar (or use ai-debug=0)

If you enable Remote debugging you can also allow other people using url parameters to see post/page with debugging data. Remote debugging option is located on the Ad Inserter Settings tab - Debugging tab below. Remote debugging enables other, non-logged in users by using url parameters to see Debugger widget and code insertion debugging (blocks, positions, tags, processing). Enable this option (and disable caching) to allow other people to see Debugger widget, labeled blocks and positions in order to help you to diagnose problems. For logged in administrators debugging via url is always enabled.

Please support the plugin if you like it:

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

Ratings

4.9 out of 5 stars

Support

37 of 38 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
100,1,1 100,1,1 100,3,3 100,1,1 67,3,2 100,1,1