How to Add Adsense to StudioPress Genesis Theme Framework

This post will help you add Google Adsense code or other advertisement codes to StudioPress Genesis Theme Framework. It is easy to add adsense code to studio press wordpress theme genesis.

Also I am a user of studiopress genesis theme framework, this is new to most of us, I really do not know how to add my advertisement codes to this theme. For the previous classic themes, I can add my codes to single.php or index.php. then add my codes to the proper codes. I can add my ads in my wordpress admin panel: click appearance,editor, find the right file, click, add my codes, save,done! But for studiopress genesis theme, you may have trouble. Don’t worry, Brain will help us solve this problem.

With the Genesis Theme Framework, adding “blocks of code” and placing them into certain areas on a site can easily be done with action hooks.

How to Add Google AdSense To Your Studiopress Genesis Theme Posts

Step #1

The first thing you’ll want to do is establish the CSS that you’ll need for the AdSense block. Inside your child theme’s style.css file, add this code:

/***** AdSense Post ********************/

.adsense-post {
float: right;
margin: 0 0 10px 10px;
}

This piece of code will create a container that will float to the right and be wrapped by the post content. If you want the AdSense block to be floated left, simply change the code to this:

/***** AdSense Post ********************/

.adsense-post {
float: left;
margin: 0 10px 10px 0;
}

Step #2

Next, you’ll want to create a file where you will place your AdSense code. You will also need to define the container for the code as well, so you create a file called adsense-post.php and place this into it:

<div><script type="text/javascript">// <![CDATA[
google_ad_client = "pub-12345678901234";     /* 250x250, created 7/28/10 */     google_ad_slot = "3220529950";     google_ad_width = 250;     google_ad_height = 250;
// ]]></script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></div>

Obviously you will replace the sample AdSense code with your own.

Step #3

Now that you have defined the style and created the php file for your AdSense code, you have to establish a way to implement it into your site. Open your child theme’s functions.php file and find this code:

// Start the engine
require_once(TEMPLATEPATH.'/lib/init.php');

Immediately after that, place the code below:

// Place Google AdSense code into post
add_action('genesis_before_post_content', 'include_adsense_post', 9);
function include_adsense_post() {
if ( is_single() )
require(CHILD_DIR.'/adsense-post.php');
}

The code above creates a function that says “if this is a single post, hook the adsense-post.php file just above the post content”. Because you defined your Google AdSense container to float: right, this allows the post to wrap itself around your box.

Of course, you can add any codes just like this. Yes, this is a little harder than the classic themes. If you do not like studiopress theme framework, you can buy ithemes premium wordpress themes, or woothemes,press75 themes etc, and we also have coupons for these themes.

Studiopress discount code: get 25% off;woothemes coupons:a lot woothemes coupon code, but most of them are expire very soon;press75 discount code: you can get 2 free;ithemes coupon code: you can get 25% off, like the studiopress. Enjoy.

studiopress adsense,studiopress add adsense,genesis adsense,genesis framework adsense,wordpress genesis adsense,studiopress adsense theme,how to add javascript to the end of each genesis post,studiopress adesne theme,how to add javascript to header php in genesis,how to put adsense code in lifestyle theme,insert adsense between paragraph in genesis,news theme studiopress adsense,not put adsense on home page with genesis hooks,place an ad above header in genesis,using adsense on genesis framework,putting adsense code into genesis child theme,how to add adsense to genesis,how to add ads to geneisis theme,addimg an ad before title genesis theme,adding adds to genesis theme wordpress