Adding AdSense to content
I would like to add AdSense top and bottom in with the content, and want to have single full posts show up from clicking on a list of links to them in the side bar.
I'm sure it's doable just wondering the easiest way to accomplish it. I tried one of the AdSense plugins but the bottom of the ad block interfered with my post text. I tried the add html, javascript box but didn't seem to work. Thanks for your help I do appreciate it! Jerry:) |
Hi again Flynn,
After reading more here http://forum.bytesforall.com/showthread.php?t=366 I thought I would quickly tell you I did donate (not much I'm unemployed like a lot of us in the USA) but I will donate for most every question I have in the future. Maybe you should have a minimum donation required for you expertise? |
Jerry, I did not plan to ignore you. Your's requires a tad more thought and I only answered the quick easy questions the last 2 days. Thank you for the donation.
Where exactly do you want to place the Adsense (before, after title etc...) The second part is not related to Adsense, right? It sound like you could just use the "Recent Posts" widget for that? A list of posts in the sidebar, and when you click on any link it goes to the single post page of that post? Or you don't want to show the recent posts, but specific posts? |
Hi Flinn,
Thanks for your response. I would like the ad block to be after the title and either above the content or within the top of the content on the left side.I got ads to show up using the "HTML/CSS inserts" box at the themes options page, but only above the header or below the footer, not within the content area. My sites going to be an informational site about "natural health remedies and cures" and will have a lot of single post pages on each specific illness, so I want the ads to show up with the full post only, no summaries at all except perhaps in the feed. I can put links to the pages via the the "text or HTML" widget although it would be nice if there was an easier way. Thanks so much for your help. I don't have much experience working with HTML or CSS which was why I decided to use your theme, as well as it's good looks!:) |
This should add an Adsense ad inside the top left of the post body on each single post page:
At the bottom of /atahualpa/functions.php add the following code, without adding/causing any blank line or blank space at the bottom of functions.php (or anywhere else in functions.php, outside of opening and closing PHP tags <?php ... ?>). PHP Code:
HTML Code:
div.bfa-adsense { |
Thanks Flinn, I'll see if I can get it done.;)
|
Hi Flynn,
I finally got some pages done and decided to add the adsense block to it. I think I did everything but don't see the ad. I'm pretty inexperienced with adding code and such so I may have done something wrong. Or perhaps it takes awhile for adsense to show up? Anyway, when you get time-no hurry at all. Thanks Flynn |
Sorry I guess a link to my blog would be a good idea.:)
|
I fixed the code above, and also expanded it a bit. Please try again.
It should add an ad into the top left of the post body on all single post pages. Alternatively you can put %adsense% somewhere into a post and that placeholder be replaced with the Adsense ad (and the default top left ad won't be displayed) To move the ad to the right, change HTML Code:
float: left; HTML Code:
float: right; To put the default ad at the bottom (left or right) instead of the top (left or right) change, in the PHP code above PHP Code:
to PHP Code:
Default LEFT or RIGHT: Adjust CSS Alternative: Put %adsense% somewhere into the post. LEFT or RIGHT will still be adjusted by CSS |
Hi Flynn,
I put the amended code in and unfortunately the ads still don't show up. Sorry Flynn, I can see you're putting a lot of time into this fix so another donation will be on it's way as I realize you aren't under any obligation to help all of us out, and I really do appreciate you're efforts on my behalf. Again, I have very little experience, although it is just copy and paste, not too difficult. Again no hurry, whenever you find the time. Thanks |
The above one is useful for me as well, my first attempt at an Adsense function so don't worry, since you've made a donation as well.
I tried the code and it worked for me. You know that a newly created Adsense code will take a while to display right? So there is not even a blank space for the Adsense ad? I just checked your post here and see an ad http://enaturesremedies.com/uncatego...st-to-see-adds Did you add that differently? |
No, but all my posts are on their own page. So if you open the page on "acne' or "pain management" I want the ads to show up there.
So I would imagine the same code will work if I just move it? |
The above code shows ads on single post pages. To show them on "Page" pages as well, change
PHP Code:
to PHP Code:
|
Thanks Flynn,
You rock!! Did you know that?:p |
Got a chance to read through this and it looks easy enough to implement. Well done.
Is there a way to make the ad only show up on the first post on the homepage (I can't have it show up on every post due to AdSense restrictions)? Also, how would you make the Ad float in the center? Well actually I guess it wouldn't look good if it was centered with text around it, but maybe just plain centered? Would you do "align: center;" instead of float? (Also, I made a small donation, it's not much but I know every bit can help and I plan to donate more later.) Thanks, Adam |
In 3.3.3 you can put this:
<?php if ( !is_single() AND !is_page() AND $postcount == 1 ) { ?> ADSENSE CODE HERE <?php } ?> above this: PHP Code:
PHP Code:
|
I hate to bother you more but I am receiving this error when I try to modify functions.php
Parse error: syntax error, unexpected '=' in ..../wp-content/themes/atahualpa/functions.php on line 691 This is not urgent, so please take your time responding if you have other things to do. p.s. using 3.2, can upgrade if that is the problem |
post #16 is for index.php, not functions.php
|
I know, I am referring to post #5. I will need the 2 codes from post #5 and the code from post #16 to make it work, right?
|
No, post #16 and #5 are different.
#16: Ad after first post on multi post pages #5: Ad inside posts/pages on single post pages and/or static pages |
Oh ok, my misunderstanding.
Is there a way to combine both of those? Ad on just first post with option of it being on page pages or not and positioned inside content? |
You should be able to use both at the same time
If your Adsense code for post #5 contains single quotes ' then you'd have to "escape" those by putting a back slash in front of each single quote \' inside your Adsense code |
Quote:
|
Quote:
2. This code will make the ad appear on the homepage along with the multi and single post pages, correct? 3. I originally had my script placed directly above PHP Code:
eadfrith: I never did figure it out, I plan to mess with the code some more today. |
try using
HTML Code:
<?php if ( !is_single() AND !is_page() AND $postcount =< 2 ) { ?> |
All times are GMT -6. The time now is 09:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.