There are four methods of the outputting of ads.
- Automatic embedding into the site content
- Widgets
- WordPress Shortcodes
- Using functions
Automatic Embedding
This method is described in detail in the section “Settings”.
Widgets
To display ads in any sidebar you can use the widgets of the SAM Pro Lite plugin. There are four widgets – Ad, Place, Zone and Block. Just drop any of these widgets to the sidebar you need and adjust it.
Title – title of widget if needed.
Ad, Place, Zone, Block – select the necessary ad object.
You can hide widget style (usually for the header widgets) and allow using predefined tags (Place, Zone).
WordPress Shortcodes
Click “Insert Advertisement” toolbar button, in opened dialog select necessary Ad Object and click “Insert” button. If necessary, check the box “Allow predefined tags”.
If you want insert shortcode manually use following code:
Where the first digit in the id is:
- 0: Place
- 1: Ad
- 2: Zone
- 3: Block
The second digit is id of the Ad Object.
Also you can use shortcodes in the WPtouch Pro Multi-Ads addon.
Using functions
Traditional
In order that would insert an Ad Object in any place of theme template, use the samProDrawAd, samProDrawPlace, samProDrawZone or samProDrawBlock functions.
Output functions are defined as follows:
1 2 3 4 |
function samProDrawAd( $id, $args, $useTags ) function samProDrawPlace( $id, $args, $useTags) function samProDrawZone( $id, $args, $useTags ) function samProDrawBlock( $id, $args ) |
- id – Ad Object id
- args – array, which may include the wrapping tags (before and after parts of tags)
- useTags – allow wrapping tags
Using Functions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// Place output if(function_exists('samProDrawPlace')) samProDrawPlace( 1, null, true ); // or if(function_exists('samProDrawPlace')) samProDrawPlace( 1, array('before' => '<div class="ad">', 'after' => '</div>'), true ); // Zone output if(function_exists('samProDrawZone')) samProDrawZone( 1, true); // or if(function_exists('samProDrawZone')) samProDrawZone( 1, array('before' => '<div class="ad">', 'after' => '</div>'), true ); // Single Ad output if(function_exists('samProDrawAd')) samProDrawAd( 1, null, false ); // or if(function_exists('samProDrawAd')) samProDrawAd( 1, array('before' => '<div class="ad">', 'after' => '</div>') ); // Block output if(function_exists('samProDrawBlock')) samProDrawBlock( 1, null ); |
Alternative
From version 2.0.0.75 you can use more flexible alternative of outputting ads. Using this method you can obtain an Ad Object and use its data as you need. For example for defining objects of Google Analitics.
For that you should use public methods getAd , getPlace , getZone and getBlock of $samProObject , it is the global instance of the main plugin’s object.
Returned object contains next public data:
- ad – HTML tags of current ad
- width – the width of ad
- height – the height of ad
- aid – ID of current ad
- pid – ID of Place (this data is not available for object returned by getAd method)
- adName – the name of ad
- eid – ID of the HTML element of ad
Using Methods:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
// Getting Ad function getMyAd() { global $samProObject; $ad = $samProObject->getAd( 1, null, false ); return $ad; } $myAd = getMyAd(); echo $myAd->ad; // Getting Place function getMyPlace() { global $samProObject; $ad = $samProObject->getPlace( 1, null, false ); return $ad; } $myPlace = getMyPlace(); echo $myPlace->ad; // Getting Zone function getMyZone() { global $samProObject; $ad = $samProObject->getZone( 1, null, false ); return $ad; } $myZone = getMyZone(); echo $myZone->ad; // Getting Block function getMyBlock() { global $samProObject; $ad = $samProObject->getBlock( 1, null ); return $ad; } $myBlock = getMyBlock(); echo $myBlock->ad; |
Disabling Ad Serving
You can disable ad serving on any post or page of your blog.
Just turn on “disable ad serving” checkbox. Ads will not be shown in this article or on this page.
© 2015 – 2017, minimus. All rights reserved.
Hi, what can i do to put some Ad in a newsletter.
I used to put a custom shortcode using $samProObject->buildAd($args, $codes) to show a banner at a newsletter editor, but after updating the plugin the banner isn’t showing anymore at my newsletter.
I replace it code by the new getAd() method but it doens’t work either.
What can i do? Thanks
What can be happening? Thanks