How to add an Adsense Ad after every post in StudioPress Genesis

Google’s Adsense Ads are a great way to earn money from your site’s traffic. Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to add an Adsense Ad after every post in a site running on the StudioPress Genesis Framework.

/**
 * Add Adsense Ad after posts in StudioPress Genesis
 *
 * @author WPSnacks.com
 * @link http://www.wpsnacks.com
 */
function ad_after_posts() {
 if ( is_single() ) {
?>
<strong>Sponsored Links</strong>
<br>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-5636129889821632";
/* WPSnacks_After_Post_Ad */
google_ad_slot = "2107218414";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<?php
}
}
add_action('genesis_after_post_content', 'ad_after_posts');

Just be sure to replace my Adsense Ad code(between the first and last “script” tags) above with your own. In the example above, the section is headed with “Sponsored Links”, which can be changed to what you would like the heading text above your Ad, just be sure you follow Google’s Adsense Guidelines.

   Related Sponsored Links

Disclaimer: The information contained in this website is for general information purposes only and in no event will this site or its owners be liable for any losses or damages associated with your use of our site or content. Click here to see our full Disclaimer.
1 comments
Emily Murray
Emily Murray

This is great thanks! Is there any way to exclude specific categories or posts that you do not want ads displayed on?