(I hope this is the right place to put this query)
My website employs a partnership program where writers have their own adsense code (different ad units from the same account) and thus they have their own ads appear on their own posts (so they get paid that way).
I had believed that I’d just be able to insert their ad code manually into their posts but the ads are not appearing. I can’t hardcode the ad code into the editor because, as I said, I need to display several ad units at a time. (1 post will have a different ad code to another).
So how can I do this? Is there a plugin that specializes in this?
Simple Ads Manager is worth checking out.
But to be clear–you are saying that each author has his/her own adsense code that you want to display in your advertisement area on your website? You want adsense code that is associated with an author to be displayed on all their posts?
Yes, they are to have their own code to be displayed on their posts.
I was going to insert them manually but I can’t do that anymore. (I could 2 years ago).
Well, I recommend trying out the Extra User Details plugin. It allows you to add new fields to the user profile section of the WordPress Backend.
Create a field where they place their Adsense code block (or you). Then place the following code into the loop where you want the adsense code displayed:
<?php the_author_meta('meta_key'); ?>
Just replace ‘meta_key’ with ‘adsense’ (or whatever you name the field on the back end).
This will work automatically on post pages, and single.php. Elsewhere, you’ll have to figure out what the author’s id, and pass it to the function as follows:
<?php the_author_meta('adsense', 26); ?>
The above block of code will get the “adsense” meta value (or, the adsense code, in our case) for user id #26.
Remember that you’ll have to add an “echo” before the_author_meta for it to print into your template.
- The topic ‘Insert different Adsense codes into different posts’ is closed to new replies.