![]() |
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; ?> |
Nice. You could also create an author ID for each sponsor and the author ID (photo/banner, website URL etc) could be added in the single.php post with %website_URL% etc.
|
| All times are GMT -7. The time now is 10:44 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123