AMP ads for all WordPress sites (AMP and Non-AMP).
This plugin generates <amp-ad>
code for your ads with breakpoints for responsive display of ad with Single Request Architecture (SRA).
Works without AMP plugin as well for Non-AMP pages.
Contributors: rtCamp, Vishal Dodiya, Pradeep Sonawane, Sagar Nasit
Tags: amp, mobile
Requires at least: 4.9
Tested up to: 5.1
License: GPLv2 or later
Requires PHP: 5.4+
Dashboard > AMP AdManager
Load AMP Resources for Non-AMP site
to load amp-runtime
and amp-boilerplate
css.Pass different ad sizes as attributes for mobile, tablet, and desktop ads. The plugin uses the width of the specified size to determine which device ad should be displayed.
728
will be considered as desktop sizes eg. 980x250,970x90
.300
and 600
will be considered as a tablet sizes eg.320x50,300x100,468x60
.300
will be considered as mobile sizes eg. 250x50,150x150
.In case of unusual sizes for desktop, tablet and mobile specific device size attribute, like
mobile-sizes
for mobile.tablet-sizes
for tablet.desktop-sizes
for desktop.[ampad ad-unit="<ad-unit-name>"
sizes="320x50,300x100,300x50,468x60,980x250,970x90"
custom-targeting="key1:value1, key2:value2" ad-refresh="30"]
[ampad ad-unit="<ad-unit-name>"
desktop-sizes="320x100,300x100"
tablet-sizes="468x60,300x100"
mobile-sizes="300x100,320x50"
custom-targeting="key1:value1, key2:value2"]
[ampad ad-unit="<ad-unit-name>"
sizes="300x100,320x50,910x150"
desktop-sizes="320x100,300x100"
custom-targeting="key1:value1, key2:value2"]
sizes
attribute and custom sizes
attrubutes can be used simutanously where custom sizes
attributes overtake sizes
attribute.
In above example 300x100
and 320x50
are for tablet and 910x150
is for desktop as per caculation on width. But since we defined desktop-sizes
as well, it will override previous desktop size of 910x150
and new desktop sizes will be 320x100
and 300x100
. Other sizes for mobile and tablet will remain intact as we have not specified custom sizes for mobile and tablet.
sizes
attribute example$attr = [
'ad-unit' => '<ad-unit-name>',
'sizes' => '320x50,300x100,300x50,468x60,980x250,970x90',
'layout' => 'responsive',
'custom-targeting' => 'key1:value1, key2:value2'
];
AMP_AdManager\AMP_AdManager::get_ads( $attr, true );
$attr = [
'ad-unit' => '<ad-unit-name>',
'mobile-sizes' => '320x50,300x100',
'tablet-sizes' => '300x50,468x60',
'dekstop-sizes' => '980x250,970x90',
'layout' => 'responsive',
'custom-targeting' => 'key1:value1, key2:value2'
];
AMP_AdManager\AMP_AdManager::get_ads( $attr, true );
$attr
(Array) These are passed directly to the get_ads
via template tag shown above or via shortcode.
Default value: array
[
'network-id' => '',
'ad-unit' => '',
'mobile-sizes' => '320x50,300x100', // consider for mobile
'tablet-sizes' => '300x50,468x60', // consider for tablet
'dekstop-sizes' => '980x250,970x90', // consider for desktop
'sizes' => '320x50,300x50,468x60,980x250,970x90',
'layout' => 'fixed',
'custom-targeting' => '',
'ad-refresh' => 30, // refresh ad every 30 seconf.
]
$echo
(Boolean) Outputs amp-ad tag if true, returns amp-ad html as value otherwise.
Single Request Architecture(SRA)
is enabled by default and Ad refresh
is disabled in default ad attributes. But SRA will not work if ad refresh is enabled.Targeting Variable | Description |
---|---|
author | - post author username (string - lowercase) |
contentType | - type of content e.g homepage, listingpage, post, page, cpt-name (string - lowercase) |
authorPage | - archive author page name (string - lowercase) |
categoryPage | - archive category page name (string - lowercase) |
tagPage | - archive tag page name (string - lowercase) |
postCategories | - post categories list (array) ["cat1", "cat2"] (all lowercase - slugs) |
postTags | - post tags list (array) ["tag1", "tag2"] (all lowercase - slugs) |
postName | - post name slug (string - lowercase) |
postId | - post id (numeric) |
feature/GH-<issue-number>-<name>
,<context>/GH-<issue-number>-<what_it_is>
.master
.postName
and postId
targeting variablespostCategories
, postTags