Community Forums › Forums › Archived Forums › Design Tips and Tricks › Placing adsense in single posts only?
Tagged: adsense, balance theme, create widget, single post, single.php
- This topic has 8 replies, 3 voices, and was last updated 10 years, 10 months ago by Brad Dalton.
-
AuthorPosts
-
June 6, 2013 at 1:53 am #44276guitarioMember
Is there a simple way to place a 728x90 adsense banner between my header image and my post headers in single posts only?
Using my previous theme I simply added the code to the 'single.php' folder but my Balance child theme doesn't have this.
So I'm assuming the code must go in the 'functions.php folder instead but can someone shed some light into where exactly and what code snippet I would need to make this work? (I don't understand php so please make it easy to understand)
Thanks
Jamie
http://www.psycholocrazy.com/June 6, 2013 at 3:01 am #44277Brad DaltonParticipantHi Jamie
You can do this several ways:
1. using CSS code
2. using PHP code
3. creating a new widget area with conditional tag3. Please copy this code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++.
Code not displaying? Grab it on Github.
You can change the hook position if needed.
June 6, 2013 at 3:43 am #44278guitarioMemberHey Brad that worked great. One thing though, now that I have placed my banner ad there, there is a large white space between the ad and the header image/top menu.
I will leave it there for you to have a look. Do you know how to reduce this, and to also leave a little white space between the bottom of the ad and the top of the post?
Thanks
Jamie
June 6, 2013 at 3:45 am #44279guitarioMemberWait, scrap the first part of that. It's because I have a lot of white space in the image header... I think...
June 6, 2013 at 4:15 am #44282Brad DaltonParticipantLine 260 of your child themes style.css file is where you can reduce the height of your header.
.header-image #title-area, .header-image #title, .header-image #title a { display: block; float: left; height: 135px; overflow: hidden; padding: 0; text-indent: -9999px; width: 350px; }
Also on line 213
#header { margin: 0 auto; min-height: 135px; overflow: hidden; width: 960px; }
You may also need to reduce the height in your child themes functions.php file:
/** Add support for custom header */ add_theme_support( 'genesis-custom-header', array( 'width' => 960, 'height' => 135 ) );
Another solution is to use a smaller banner and use a different hook like genesis_before_post_title or genesis_after_post_title
June 6, 2013 at 5:02 am #44283guitarioMemberThanks Brad that worked a treat!
One last thing while you're here... How can I create a bit more white stuff after the banner? It seems very squashed against the top of my post where the date is and the heading on my sidebar.
You've been a great help
Jamie
June 6, 2013 at 6:35 am #44286Brad DaltonParticipantYou can add some padding to the new widget area http://www.w3schools.com/css/css_padding.asp
.before-content { padding-bottom: 24px; }
I couldn't see the Adsense banner on single posts so cannot inspect the element using Firebug.
October 29, 2013 at 8:39 am #69631hobbygirl66MemberHow could you change this to include pages as well?
Thanks!
LisaOctober 29, 2013 at 9:38 am #69650Brad DaltonParticipant -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.