If you would like to add Google AdSense advertisements to your genesis framework theme, here is the method I use. These instructions assume your genesis child theme is using html5. If you are not using an html5 child theme, the code below will need to be modified slightly.
1. Add the following 2 code sections to your genesis child theme functions.php
Register 2 new widget areas
genesis_register_sidebar( array( 'id' => 'wpselect_before_post_content', 'name' => __( 'Before Post Content', 'genesis' ), 'description' => __( 'Displays on single posts before post content.', 'genesis' ), ) ); genesis_register_sidebar( array( 'id' => 'wpselect_after_post_content', 'name' => __( 'After Post Content', 'genesis' ), 'description' => __( 'Displays on single posts after post content.', 'genesis' ), ) );
Insert new widget areas into single posts
add_action( 'genesis_before_entry_content', 'wpselect_before_post_content' ); function wpselect_before_post_content() { if ( is_single() ) { genesis_widget_area( 'wpselect_before_post_content', array( 'before' => '<aside class="wpselect_before_post_content widget-area">', ) ); } } add_action( 'genesis_after_entry_content', 'wpselect_after_post_content', 1 ); function wpselect_after_post_content() { if ( is_single() ) { genesis_widget_area( 'wpselect_after_post_content', array( 'before' => '<aside class="wpselect_after_post_content widget-area">', ) ); } }
2 Add the following code to your genesis child theme style.css
.wpselect_before_post_content .widget { float: left; padding-bottom: 10px; padding-bottom: 1rem; padding-right: 24px; padding-right: 2.4rem; } .content-sidebar .wpselect_before_post_content .widget, .content-sidebar-sidebar .wpselect_before_post_content .widget { float: right; padding-left: 24px; padding-left: 2.4rem; padding-right: 0px; padding-right: 0rem; } .wpselect_after_post_content .widget { clear: both; margin-bottom: 26px; margin-bottom: 2.6rem; margin-top: 26px; margin-top: 2.6rem; text-align: center; }
The css listed above may need to be tweaked depending on your genesis child theme css. The css above places the adsense ads as recommended in the google adsense help document for blog articles. The sidebar ad can be placed in your primary sidebar.
3. Add google adsense code to text widgets
Your theme will now have 2 additional widget ares under Appearance > Widgets. The widget areas are titled Before Post Content and After Post Content. You need to drag a text box widget into each of these widget areas and place the appropriate google adsense code into each text box. I hope these instructions help you to add adsense advertisements into your genesis framework theme.
I’m using Genesis and the lifestyle pro child theme and for some reason this did not work for me. I’m really wanting to add adsense into Genesis without a plugin:)
thanks:)
LikeLike
Can you provide more details on what is not working. Are you using an html5 genesis child theme?
LikeLike
Do you have guide for html5 child themes?
Thank you
LikeLike
The code in this post should work on an html5 child theme.
LikeLike
I’m a bit confused. There are only two widget areas, but when you look at the positioning google recommends, there are 3 areas. Which 2 areas does this correspond to? And does it work for the homepage?
LikeLike
For the third widget area, just use your traditional primary sidebar with a skyscraper ad. The 2 areas for the code above correspond to the ads within an individual post.
LikeLike
John:
Thank you for posting this as it’s the first piece of code I’ve found that actually worked in the requisite spots.
Just switched from Thesis to Genesis and still getting my sea legs.
The issue that I’m having is that because it’s on my wife’s recipe site with a post image as the first piece of content it’s not placing the ad after the image and is pushing it down and leaving a lot of white space next to the ad above the fold.
Any thoughts on how I would fix that?
LikeLike
Sounds like it’s a CSS issue. Would need to view the site to be able to help.
LikeLike
Hi I am using Genesis I want to place ads just below the navigation and bread crumbs (on the post page)
Please can you tell me How I can do that ?
LikeLike
Hi, this was a big help to me on putting an additional widget on my child theme. Actually I only used your before post content widget because my Magazine Pro child theme already have an after post content widget.
It worked like a charm!
LikeLike
Thanks for the great post!
If i want the before post widget to be on the right side of the page do i just swap where it says left and right in the third box of code?
LikeLike
That should work. You may also want to change the references to padding-right on lines 5 and 6 to say padding-left.
LikeLike
Worked for me! Thank you for saving my time…
LikeLike
Thanks you for saving my time ..
Worked for me !
LikeLike