Pl
wordpress plugins

Ad Inserter

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

plugin Ad Inserter
4 out of 5 based on 31 user ratings.

Description

Version: 1.6.7

Need to install ads or widgets on WordPress website?

Ad Inserter is a simple yet powerful solution to insert any code into WordPress. Perfect for AdSense or contextual Amazon ads. Simply enter any HTML/Javascript/PHP code and select where and how you want to display it.

Ad Inserter supports up to 16 code blocks. Code block is any code (for example AdSense ad) that has to be inserted (displayed) at some position. Each code block can be configured to insert code at almost any position supported by WordPress.

Features
16 code blocks
Syntax highlighting editor
Automatic positions: before/after post, content, paragraph or excerpt
Manual positions: shortcodes, PHP function call
Block alignment and style: left, center, right, float left, float right, custom CSS, no wrapping
PHP code processing
Server-side and client-side device detection (3 custom viewports)
Black/White-list categories, tags, urls, referers

And there is also Ad Inserter Pro if you need more than 16 code blocks or more than 3 viewports.

Quick Start

You need to know two very important things in order to insert code and display some ad:You need to enable and use at least one display option (Automatic Display, Widget, Shortcode, PHP function call)
You need to enable display on at least one WordPress page type (Posts, Pages, Blog pages, Homepage, Category pages, Search Pages, Archive pages)

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

Settings

Each code block has 4 independent display options:Automatic Display
Widget
Shortcode
PHP function call

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

Automatic Display Options:Display Before Post (before post or posts on blog pages, previously named Before Title)
Display Before Content (before post or page text)
Display Before Paragraph (on posts, pages and blog pages)
Display After Paragraph (on posts, pages and blog pages)
Display After Content (after post or page text)
Display After Post (after post or posts on blog pages)
Display Before Excerpt (on blog pages)
Display After Excerpt (on blog pages)
As a Widget - Simply drag Ad Inserter widget to any widget postition (e.g. Sidebar), select code block, save and you're done.

For single posts or pages display 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 pages display 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.

Display Block to:All users (default)
Logged in users
Not logged in users

WARNING: If you are using caching this may not work as expected. The check works only when the page is generated and Ad Inserter is called. Make sure you have disabled caching when you are using such settings.

Order of display positions in a typical post is the following:[Before Post]
Post Title
[Before Content]
Paragraph 1
Paragraph 2
Paragraph ...
Paragraph n - 1
Paragraph n
[After Content]
Comments
Output of some other plugins
[After Post]

Of course, the final order of items depends also on other plugins. Ad Inserter is by default called as one of the last plugins. You can change Plugin priority on the settings page (tab #).

Block Alignment and Style:No Wrapping (leaves ad code as it is, otherwise it is wrapped by a div)
Custom CSS (You can define custom CSS code for wrapping div)
None (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)

Check screenshots for explanation on alignment.

PLEASE NOTE: If you are using No Wrapping style and need to hide code on some devices using client-side detection (CSS Media Queries) then you need to add appropriate class to your CSS code (ai-viewport-1, ai-viewport-2, ai-viewport-3). This doesn't apply to widgets as they always contain a wrapping div.

For all display positions you can also define WordPress page types where the ads can be displayed. PLEASE NOTE: Regardles of other settings you need to enable display on AT LEAST ONE PAGE TYPE:
Single pages:Posts
Pages

Blog pages:Homepage
Category pages
Search Pages
Archive pages

You can also disable ads on certain posts or pages. For each code block on posts or pages you first define default display settings for posts/pages page type. Then you can define post/page exceptions on the post/page editor page (check Ad Inserter Exceptions meta box below). Exceptions work only on page/post content (positions Before Content, Before Paragraph, After Paragraph, After Content). For one or few exceptions it is easier to first enable ads on All Posts/Pages page types and then either white or black-list single url or few space-separated urls (click on the Lists button).

For blog pages and display positions Before Excerpt / After Excerpt and Before Content / After Content you can also specify excerpt/post number or comma separated list of excerpt/post numbers (1 - 9). For Before Post / After Post positions this setting is a filter to limit/filter insertions before or after post if the theme inserts code block more than once. You can also leave Excerpt/Post number to 0 (means all posts on the blog page) and define maximum number of insertions.

Please Note Paragraph processing works on every post or page according to settings. Therefore, if you enable display also on blog pages (home, category, archive, search pages) and your theme does not display post excerpts but complete posts, Ad Inserter will by default insert code blocks into ALL posts on the blog page (according to settings). To enable insertion only into specific post(s) on blog pages define Excerpt/Post number(s). You can also leave Excerpt/Post number to 0 (means all posts on the blog page) and define maximum number of insertions.

Paragraph number for Automatic Display options Before and After Paragraph:0 means random paragraph position
value between 0 and 1 means relative position in post or page (e.g. 0.3 means paragraph 30% from top or bottom)
1 or more means paragraph number

Paragraphs can be counted from top or from bottom. It is also possible to count only paragraphs that contain/do not contain certain text or count only paragraphs that have some minimum number of words. If more than one text is defined (comma separated) and "contain" is selected then the paragraph must contain ALL texts.

You can also define paragraph HTML tags. Normally only

tags are used. If your post contains also

or header tags, you can define comma separated list of tags used to count paragraphs (e.g. p, div, h2, h3). WARNING: Each code block you insert in post adds one
block unelss you use No wrapping style. Before Paragraph will insert code before , After Paragraph will insert code after closing . After Paragraph will not work if you specify tag names that have no closing tags! Use # as tag if paragraphs have no tags and are separated with the \r\n\r\n characters.

Minimum number of paragraphs / Minimum page/post words: do not display ad if the number of paragraphs or the number of words is below limit (used only for position Before or After selected paragraph).

Display only for posts published after N days checks the date when the post was published.

On the Ad Inserter settings page (tab #) you also have option Tag Debugging. If enabled, it displays paragraph tags surrounded with a border. This way you can check where your code will be inserted. You can select to show paragraph tags before or after plugin processing. If Before Processing is selected Ad Inserter WILL NOT insert any code!

Additional Display Options:Manual - Insert shortcode [adinserter block="BLOCK_NUMBER"] or [adinserter name="BLOCK_NAME"] into post or page HTML code to display block with BLOCK_NAME name or BLOCK_NUMBER number at this position.
PHP function call - Insert code block BLOCK_NUMBER at any position in template file. With PHP function call counter (Excerpt/Post number) you can also define which call(s) to the function will actually insert code. This is useful if you put a call to the adinserter function inside a loop in a template file (e.g. for homepage) and you need to insert ads only few times between posts.

Additional Options for code blocks:
PHP processing: Enabled or Disabled - Enable processing of PHP code. If there is an error in the PHP code, it will not break the website.
Use {category}, {short_category}, {title}, {short_title}, {tag}, {smart_tag} or {search_query} tags to insert actual post data into code blocks
Use {author} for post author username or {author_name} for post author name to insert post author data into code blocks (works only inside posts)
To rotate different ad versions separate them with |rotate| - Ad Inserter will randomly select one of the ads

WARNING: If you are using caching ad rotation may not work as expected. It works only when the page is generated and Ad Inserter is called. In such cases please make sure you have disabled caching when you are using |rotate|.

Ad Inserter is perfect for displaying any kind of ads. It can also be used to display various versions of ad, for example AdSense ads using channels to test which format or color combination performs best.

Lists

Do not display ads in certain caregories e.g sport, news, science,... (black list) or display ads only in certain categories (white list): leave category list empty and set it to Black list to show ads in all categories. WARNING: If category name contains commas use category slug instead. Also make sure you have enabled display on Category pages.

Do not display ads in posts with certain tags (black list) or display ads only in posts with certain tags (white list). Leave tag list empty and set it to Black list to show ads for all tags. Also make sure you have enabled display on Archive pages.

Do not display ads on pages with certain urls (black list) or display ads only pages with certain urls (white list): leave url list empty and set it to Black list to show ads on all urls. Url used here is everything starting form the / after the domain name. For example: if web address is http://domain.com/lorem-ipsum, url to white/black-list is /lorem-ipsum You can also use partial urls with *. To filter all urls starting with /url-start use /url-start*, to filter all urls that contain url-pattern use *url-pattern*, to filter all urls ending with url-end use *url-end. WARNING: Separate urls with SPACES.

Do not display ads to users from certain referers (domains) e.g technorati.com, facebook.com,... (black list) or display ads only for certain referrers (white list): use # for no referer (direct visit), leave referrers list empty and set it to Black list to show ads for all referrers.

WARNING: If you are using caching, referer check may not work as expected. It works only when the page is generated and Ad Inserter is called. Make sure you have disabled caching when you are using such settings.

Devices

IMPORTANT: There are two types of device detection: server side and client-side.

Client-side detection
Desktop devices
Tablet devices
Phone devices

Client-side detection of mobile/desktop devices works always as it is done in visitor's browser. CSS media queries and viewport (browser's screen) width are used to show or hide Ad Inserter code blocks:
PLEASE NOTE: In most cases you should use ONLY client-side detection type. Works perfectly with responsive designs as they use CSS media queries.

BUT BE CAREFUL: Some ad networks (like AdSense) limit ads per page. The ads are still inserted (loaded and counted) for all devices, but for unwanted devices they are hidden by the browser using CSS media queries based on viewport widths.

Up to 3 viewport names and widths can be defined on the Ad Inserter Settings tab # (Ad Inserter Pro supports up to 6 viewports). Default values are:Desktop: 980 pixels or more
Tablet: from 768 pixels to 979 pixels
Phone: less than 768 pixels

Server-side detection
Desktop devices
Mobile devices (tablets and phones)
Tablet devices
Phone devices
Desktop and tablet devices
Desktop and phone devices

Server-side detection of mobile/desktop devices works only when Ad Inserter plugin is called. It is called by WordPress when it needs to generate a page. However, when you are using caching, it saves created page for quicker serving. In such cases the user might get (saved) page for wrong device (used by some previous visitor who triggered page caching). To solve this issue use themes that generate separate pages for desktop and mobile devices or use Mobile Theme Switcher plugin. Server-side detection uses User-Agent string combined with specific HTTP headers to detect the environment.

PLEASE NOTE: Use server-side device type detection only when you need to generate (display and count) ONLY code blocks for specific device type. In all other cases switch it off.

By default code blocks will not be inserted on Error 404 page (Page Not Found). Check Error '404 Page checkbox' to enable code block on error 404 page.

Ad Inserter Settings - Tab #

Wrapping divs for code blocks have 'code-block' and 'code-block-N' classes which can be used for custom styles. Class name 'code-block' can be changed in Ad Inserter settings. If you are using client-side device detection (CSS media queries) then the wrapping div for the code block will have also some of the following classes: ai-viewport-1, ai-viewport-2, ai-viewport-3.

You can choose between many syntax highlighting themes.

By default Ad Inserter exceptions on posts/pages are enabled only for administrators. You can define minimum user role for page/post Ad Inserter exceptions editing in Ad Inserter Settings (tab #).

Default Ad Inserter plugin processing order is 99999. It is used to specify the order in which the plugin functions are executed. Lower numbers correspond with earlier execution. You can change this value if you have problems with the processing order of other plugins.

If Paragraph Tag Debugging is enabled, it displays paragraph tags surrounded with a border. This way you can check where your code will be inserted. You can select to show paragraph tags before or after plugin processing. If Before Processing is selected Ad Inserter WILL NOT insert any code!

Support for Special Code Blocks:Header scripts (scripts in the
section)
Footer scripts (scripts before the tag)

WARNING: Text selection, Copy and Paste functions with the syntax highlighting editor do not work on mobile devices. If you need these functions you can temporarily swich to Simple editor using the checkbox above the code box.

WARNING: Some adblockers may block Ad Inserter settings page. If you don't see normal tabs for code blocks or there is no save button, make sure you have whitelisted Ad Inserter settings page.

WARNING: If you are using caching the inserted code may not appear imemdiately on the page. Make sure you have disabled caching when you are testing or debugging. Some caching plugins like WP Super Cache have an option to disable caching for known users.

WARNING: If you are using caching some settings may not work as expected. For example, ad rotation, referer check and server-side detection works only when the page is generated and Ad Inserter is called. In such cases please make sure you have disabled caching when you are using such settings.

SUPPORT

If you experience problems with the Ad Inserter plugin you can ask for help on the support forum. However, in order to be able to diagnose the problem and suggest actions or fix a bug, please do the following:
Check source code of the page. Some code for ads may not display anything, either because of errors in the ad code or because of ad network issues. Before you report problem please check source code of the page and make sure the code is not inserted where it should be. The code may be inserted properly but you won't see anything. Try to add some text after the ad code to check if it appears at the expected ad position. If you are sure that there is something wrong you need to provide the following:
Clear description of the problem. Describe what does not work as expected.


Screenshot(s) of the settings


Web addresses (links) of the pages where the code from the settings above is not inserted properly.


Unless you provide the items listed above nobody can check your website, can't reproduce the problem and consequently can't help. Thank you very much for understanding.

Tags: ad, ads, adsense, amazon, banner, banner rotation, category, cj, clickbank, code, contextual, custom css, desktop, filter, footer, header, html, javascript, logged in, mobile, not logged in, phone, php, responsive, rotating, shortcodes, sidebar, skip, tablet, tag, url, users, viewport, widget, widgets

Tags

Requirements

Requires: 4.0 or higher
Compatible up to: 4.5.3
Last Updated: 6 days ago
Active Installs: 30,000+

Download URL

https://downloads.wordpress.org/plugin/ad-inserter.1.6.7.zip