Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to add Adsense beneath blog post title
Tagged: adsense
- This topic has 10 replies, 4 voices, and was last updated 11 years, 3 months ago by raunekk.
-
AuthorPosts
-
January 4, 2013 at 11:25 am #9515fskhan619Member
How to add Adsense beneath blog post title? I'm using Focus Child theme.
January 4, 2013 at 12:11 pm #9538AnitaKeymasterInstall Genesis Simple Hooks - http://wordpress.org/extend/plugins/genesis-simple-hooks/ and then activate it.
Look for the box that says - genesis_after_post_title
Paste your code in there and save it.
Love coffee, chocolate and my Bella!
January 4, 2013 at 12:24 pm #9541buddy_boy8403ParticipantI did this for a client. What I did was create a new sidebar area (Nick The Geek has a good tutorial on how to do this on his website). You need to reference the appropriate genesis hook in the sidebar code - StudioPress has a hook reference to help you out with this.
You can try this and see if this is what you need. Just add the code to your child theme's functions.php file and the styling to your child theme's style.css file:
/** Start Add Sidebar After Content */
// First we have to register the new sidebar
genesis_register_sidebar( array(
'id' => 'after-content-ad',
'name' => 'Bottom Of Page Ad Area',
'description' => 'This is a sidebar that goes after the content.',
) );
// Next we have to display the sidebar
add_action( 'genesis_after_content_sidebar_wrap', 'child_after_content_ad_sidebar' );
/** Loads a new sidebar after the content */
function child_after_content_ad_sidebar() {
// Now we add the conditional to show this everywhere except the home page by putting an ! in front of is_home()
// For more info about conditional tags, see: http://designsbynickthegeek.com/tutorials/conditional-page-content
if (is_single() ) {
echo '';
dynamic_sidebar( 'after-content-ad' );
echo '';
}
}
// Finally we need to style the sidebar in the child theme's style.css file
/** End Add Sidebar After Content */Now for the CSS styling
/* Ad Sidebar
------------------------------------------------------------ */
.after-content-ad {
clear: both;
margin: 0 auto;
width: 728px;
}January 4, 2013 at 12:25 pm #9542AnitaKeymasterI think the code you pasted broke.
Love coffee, chocolate and my Bella!
January 4, 2013 at 12:27 pm #9544buddy_boy8403ParticipantI think the code you pasted broke.
I fixed it - thanks.
January 4, 2013 at 2:32 pm #9560fskhan619MemberThanks both of you ..! Genesis Simple Hooks works best but I wan't the ad to appear on the post page only, not on the homepage. Can you show me how can I do that?
January 4, 2013 at 3:13 pm #9571buddy_boy8403Participant@fskhan619 - The code I gave to modify your functions.php file does this. Thats what the following conditional does in that snippet:
if (is_single() )
Just copy/paste that to the bottom of your functions.php file, update the styling in your style.css file and modify the styling to suite your needs.
Once you create the new widget area, just go to your Appearance > Widgets page, drag a text widget in there and paste the adsense code. After that, you should be good to go.
January 4, 2013 at 6:09 pm #9613AnitaKeymaster@fskhan619 - here is the code you need. I hope the code posts.
<?php if(is_single()) { ?>
<center>
***Paste AdSense Code Here***
</center>
<?php } ?>
Love coffee, chocolate and my Bella!
January 5, 2013 at 5:12 am #9708fskhan619MemberIt works perfectly and thanks a lot for replying and helping! But the widget lets you add content at the bottom of the page beneath the content and I want to add adsense (large rec) beneath the Post Titles.
January 5, 2013 at 9:13 am #9720buddy_boy8403ParticipantThen try adding this to your functions.php file. Don't remove the one you just put in there from your functions.php file in case later on down the road you wanted to use it. Just don't drag any widgets to that sidebar:
/** Start Add Sidebar Before Post */
// First we have to register the new sidebar
genesis_register_sidebar( array(
'id' => 'before-posts-sidebar',
'name' => 'Before Posts Ad Area',
'description' => 'This is a sidebar that goes before the post content.',
) );
// Next we have to display the sidebar
add_action( 'genesis_before_post_content', 'child_before_posts_sidebar' );
/** Loads a new sidebar before the posts in the #content */
function child_before_posts_sidebar() {
// Now we add the conditional to show this everywhere except the home page by putting an ! in front of is_home()
// For more info about conditional tags, see: http://designsbynickthegeek.com/tutorials/conditional-page-content
if (is_single() ) {
echo '
';
dynamic_sidebar( 'before-posts-sidebar' );
echo '
';
}
}
// Finally we need to style the sidebar in the child theme's style.css file
/** End Add Sidebar Before Post */January 5, 2013 at 10:16 am #9728raunekkParticipantUse "quick adsense" plugin. It's quite helpful with a lot of features.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.