Insert per author ads on posts to share revenue (it works even if you are the only blog author!)
FOR MEMBERS ONLY
Multi Author Ads is a simple but effective plug-in for who have a multi authored blog and want to insert different ads on posts of different authors (maybe to share revenues). Once upon a time, AdSense codes from different account differs only for the publisher id so it was easy to change the ad owner. Now with new AdSense codes it’s no more easy ’cause there is the “slot” new field.
With Multi Author Ads in a single control panel you have all your user listed and, as administrator, you can set what will be displayed on top and on bottom of every post… by author. authors an give you the ad snippets of JavaScript or HTML for their posts.
Of course if you blog has a single author (you!), Multi Author Ads can be still used to insert ads in posts, but maybe it’s easy to user Post Layout or Post Layout Pro.
There are some “default” code bocks to add other things, eg. a Facebook share button, which are author independent. Those blocks let you to add something before and after author’s codes.
Every block of code can accept PHP script snippets as well, so you can add full programmatic logic to every single “insertion”. See below for PHP usage examples.
Here a screen shot of Multi Author Ads configuration panel (click to zoom).
On picture above an example of configuration for a blog with three authors: admin, elena and chiara.
Using PHP
It’s possible to use PHP on code blocks. The usage of PHP is for really advanced users and a simple way to add some specific function by consultants without having them to develop a full plug-in (…saving money…).
To use PHP just insert a PHP script like the one below:
<?php echo "just a test"; ?>
F.A.Q.
I need to add some code but only when a post is in a specific category.
[private]
Given the category number, you can “wrap” the code that you want to show only for post in that category this way:
<?php if (is_in_category(15)) { ?>
[code]
<?php } ?>
where "15" is the category number. WordPress allow to use a slug to identify a category, so the code can be modify to use the category slug/name:
<?php if (is_in_category('category name')) { ?>
[code]
<?php } ?>
just experiment a little, sometime character case matters. If you need to add a code whe a post is in one or more categories the PHP is a little worse:
<?php if (is_in_category(array(14, 28, 34)) { ?>
[code]
<?php } ?>
where "14", "28", "34" are category numbers. As in example above, the category name/slug can be used:
<?php if (is_in_category(array('news', 'house-keeping', 'children')) { ?>
[code]
<?php } ?>
[/private]
I need to add some code only when a post is NOT in a specific category.
[private]
I use that when a post has some content against the TOS (Term of Service) of ad networks, so I classify those posts in a special "marker" category. The PHP code to block ads injection for such posts is:
<?php if (!is_in_category('marker category') { ?>
[code]
<?php } ?>
note the "!" symbol. Of course a programmer can create a lot of more complex condition (I usually do for some blogs).
[/private]
How can I add the Facebook like button? does Facebook button goes bad with AdSense?
Adding the Facebook like button is really simple. Facebook like button is available in two form: as an iframe and as a fb:like special tag. The formes is easy to insert, the latter works better. If you use AdSense in your site, surely you need the fb:like special tag, because the iframe version badly interact with AdSense slots.
[private]
To add a Facebook like button you need two things: the fb:like code on every posts (usually before or after the post content) and a special code to be added on page footer that activate the fb:like tag.
On Multi Author Ads there is a way to add footer code on each page (like with my Header and Footer plugin). What you need to add is:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: '148232251860808', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
Then just add the fb:like tag code before or after the post content, of course using the configurations of Multi Author Ads:
<fb:like href="<?php echo htmlspecialchars(get_permalink()); ?>" layout="standard" show_faces="true" width="450"></fb:like>
This tag can be customized with a number of attributes. Note the PHP code that extract the current post URL. More about this Facebook like button can be found here. Clearly this button is now "theme independent": you can change your theme but the button will be always placed on any posts!
The result? Here a screenshot:
[/private]
by Stefano Lissa



