View Single Post
Old 03-10-2013, 03:33 PM  
mromro
So Fucking Banned
 
Industry Role:
Join Date: Jan 2011
Posts: 770
How to Display Specific Sponsor Ads on Posts in Wordpress

I was looking for a plugin that would display certain ads on post according to sponsors but couldn't find one.

I decided to use custom fields and edit the single post php. I'm sure this is simple for the pros out there but it drove me nuts for a while. I'm not too good at php.

this is how I did it if anyone needs it too.

add custom field called "Advertisement" with the URL to the banner location

add custom field called "Ad URL" with sponsor affiliate link

edit theme and add this code to display banner where you want on single post:

<?php if( get_post_meta($post->ID, 'Ad URL', true) && get_post_meta($post->ID, 'Advertisement', true) ) : ?>
<a href="<?php echo get_post_meta($post->ID,'Ad URL',true); ?>">
<img src="<?php echo get_post_meta($post->ID,'Advertisement',true); ?>" />
</a>
<?php endif; ?>
mromro is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote