Add Google AdSense to Genesis Framework Theme

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

Genesis AdSense WidgetYour 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.

14 thoughts on “Add Google AdSense to Genesis Framework Theme

  1. 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:)

    Like

  2. 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?

    Like

  3. 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?

    Like

  4. 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!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.