Yuma 4×4

Media and Communications

How to Add Google AdSense Code inside a WordPress Post

How to Add Google AdSense Code inside a WordPress Post

how to add Google AdSense code
inside a WordPress post hello and welcome and in this quick video session I’m
going to show you a simple method and for you to be able to add your
Google AdSense code anywhere within your post as I’ve shown
you it was very simple to add it on your sidebar right but what if you wanna add it somewhere else and have more control over where the Ad appears simply you grab the code that you’ve generated
in Google AdSense so if you haven’t done so you
login and create an Ad unit right now once you do
what you do is you login into your dashboard in your WordPress site go under appearance here and let’s
go under editor now these are all the core files that
actually fires your WordPress site now I would strongly encourage you not
to play around with these apart from what I will show you unless
you know what you’re really doing okay so what I’ve done is I’ve located
the functions dot PHP file which all WordPress sites have
regardless of the theme that you’re using okay and what I do is I scroll down towards the end of the functions.php file and what I do is
let me quickly just create this function bare with me this is very simple okay I’m not gonna go through
explaining everything because it’s too simple by name it anything I want up okay okay now that’s all I need here okay and when I do is I simply paste that Google AdSense code inside that return code element there right so that’s all I’ve done now what’s next next is simply when I need to do is I need to have access to this function
that I’ve just created and I need to add a short code let me create this code will be available in
description of this video so what I put here is I say okay add to appear add to appear here and the I simply copy the name of the function copy and paste inside this apostrophe okay so simply I paste that in there and that’s all there is to it now what’s next I simply hit update file now once I do and let’s go inside this post that I had right and let’s add our Google AdSense code just here and let’s add one here as well its here okay let’s add it in two places let’s find that post we locate posts and this is the post that we’ve just seen
before let’s edit that and let’s choose we’ve got two
different options one visual one text this choose text and here and what we do is and bare with me because I forgotten the name of the function I’ve just created
bare with me let me open that function file up where was it down the bottom add to appear here silly me now add to appear where ever I want right I just do this and I just paste that name that I’ve
created let me copy that short code now let me copy that
and let me put it just under here as well let me paste that and let me update that file and once I
do now all I have to do to is simply hit refresh and voila I have total control of where the Google AdSense appear within my posts anywhere I
can add them anywhere and not just the sitebar as you can see it is very simple the code will be
available surely you change the what goes here you simply you add your own so this code will
be available in the description and then it’s just matter of putting it in brackets and then calling that name whatever you
named it as add to appear you can say ABC whatever right if I was to say ABC okay and I just copy that then I would surely call it as such okay and then when I update same thing
would happen so that means I would show ads anywhere that I want within the content of
the post itself or the page okay I thank you very much for your visit and
if you operate a WordPress site I have many different video tutorials
that show you many useful insights thank you for learning with me I’ll talk
to you very soon happy rankings thank you

100 thoughts on “How to Add Google AdSense Code inside a WordPress Post

  1.  "I've just tried that code on my blog, following absolutely every single step. The result, I receive an error message and no longer live."

    same thing has just happened to me  

  2. I just tried and get error. :'( help! I am new.
    Warning: Cannot modify header information – headers already sent by (output started at /home/kliatwo/public_html/cn/wp-content/themes/truepixel/functions.php:954) in /home/kliatwo/public_html/cn/wp-admin/post.php on line 235

    Warning: Cannot modify header information – headers already sent by (output started at /home/kliatwo/public_html/cn/wp-content/themes/truepixel/functions.php:954) in /home/kliatwo/public_html/cn/wp-includes/pluggable.php on line 1121

  3. Wow!  Awesome video.  I really appreciate you doing this.  I'd been trying to figure this out for a few days, searching high and low for decent advice, and you totally nailed it.  Definitely bookmarking this for future use.  Thank you.

  4. Can you add this function multiple time to put different size ads in? I try doing this and got the dreaded WPOD screen and thought i lost my site!

  5. Actually for me it worked without everything you just showed. I simply openned the post, went to "text" copied my adcode there and it appeared on the page 🙂 Still very good tutorial and you explained it very well. Can probably use this code for other things as well. Something that I often post on my page.

  6. You are so good man, It worked so well. I just hope that now I can complete my review and get some real ads on my site 😀 !! Subscribed + Liked + Commented! Awesome stuff! 

  7. Hi,
    Than-You for your video. I have a challenge. How can I add 2 different adsense ads using this code? I have already added one But when i try to add a seperate add i get an error message that says this:        Fatal error: Cannot redeclare myAdSenseCodeFunction()

  8. I followed your steps EXACTLY as you showed. My site now has an Internal Server Error that I can't fix. It won't even let me go in to repair the damage. What the heck and how do I fix that?

  9. Hi,

    I edited the funtion php file and after updating it my wp-admin and my regular website are not running at all. It's a blank screen. 

  10. Hey @rankyaseoservices,
    Your video is great. I have a problem, when I add the code in the "functions.php" section and click "update file", I'm sent to an error page saying: "Cannot modify header information"
    I've check for syntax errors [Spelling of function's name, single quotes outside of AdSense code that has double qoutes, add the semicolon to the end of code, etc…]
    I also double checked to make sure I was editing functions.php and not header.php
    I not sure what or where the problem is.
    Also the type of Adsense I'm using is "Link ads" size and type.
    If needed, I can code & paste the code I placed in functions.php  

  11. Parse error: syntax error, unexpected end of file in /home2/****/public_html/wp-content/themes/customizr/functions.php on line 65

  12. It worked on my computer and my iPad, but my phone is coming up with [adToAppearHere]? please help, thanks!

  13. Hi, is there any way to make the ads responsive. Everything work fine other than the ads in the post are not responsive.

  14. Code worked for me the first time. Thank you for the simple explanation!,

    Unfortunately, ad shows, but its not big size 336×280 that I've chosen in the Google, but some smaller size. No matter how I insert the code I always get small ads, instead of big ones. If I insert code into Appearances / Editor / page.php than I get big size ads, but they can not be inside the text, only at a top or bottom of the page.

    Do you have any idea how to force ad code to show big ads inside the content of the post or page, after, say, the first or second paragraph?

  15. Oh man, I did The code placement of the first part, but now, at the top of my site I see this code, and it makes it look all sloppy, so disappointing!

  16. I follow your tutorial after i click update my site was go i cant even access my back end anymore or my site.

    Please what can i do to bring back my site?

  17. hi your tutorial was awesome i doubt can you clear??? please I am using COLORMAG wordpress theme I want to insert Google adsense code just before the post 300*250 size this code will work or anything can you clear me please ………….

  18. dear frnd i liked your way of making understand it very easy and usefull i was followed your instructions but when i saw my wordpress site there is no option for me to APPEARANCE and EDITING section but how ever i just copied and paste my adsense code in my regular post to check the adds but after doinfg this i m unable to see it in my post view

    can u plz help me regarding to solve this problem?

  19. So whenever I want to add a new code, I'd have to create another function and generate a new short code at functions php?

  20. I try this at my blog wordpress post

    It doesnt work for me..Add is not displaying But a huge space only?

    When i did all the procedure according to video..After the update the post…There is a huge space showing in the website main interface where add is submited

  21. Didn't work on my WordPress.org site, and I did it exactly the way you described it. It only resulted in large blank spaces between paragraphs.

  22. I found appearence but sorry in the appearance the option "editor" isn't there . can you explain me step by step how to have edit please for the script

  23. My adsense account is under review and I have to add the code in the body of the HTML page. Where do I find the body?

  24. Great solution to keep wordpress from adding linebreaks and p tags to in-post Adsense code.. I'm glad I didn't have to install another plugin. Thanks for this. Let's hope it works forever.

  25. I did everything just fine, then when I clicked update file, it brought me to a blank page. So I went back and tried again. Still not working. I figured it was a browser problem, so I deleted the tab and opened it up in Safari. Then on safari it was just a blank page. So I went back to firefox, an when I open it up it is just blank. So I can't even open back up that page to delete that whole code. Now my blog is pretty much toast.

  26. Hello do i've downloaded the zip file u said to download in it there is file custom_function_for_AdSense.php what to do with this file do i need to place it in wordpress or what i didn't understand please help

  27. Nice tutorial, but how to you let the text wrap around the ad, instead of leaving that huge white space. It doesn't look professional. Is there a html function to make this possible?

  28. Hi, what about the adsense policy that I just can show max 3 ads? Is it possible to copy paste all over the place I want? Thank you

  29. For Me it created big problems , domai is currently unable to handle this request.
    HTTP ERROR 500, and it took lots of efforts undo it, is there any alternative options?

  30. can I remove free themes in the footer powered by WordPress and theme credit link? for trial and premium themes without purchasing this themes

  31. Parse error: syntax error, unexpected '' adTOAppearHere'' (T_CONSTANT_ENCAPSED_STRING) i got this error after added code to my wordpress theme
    what should i do
    could you help me

  32. Hy , Thanks for this tutorial , I have follow everything mention , but after update the post , only 1 or 2 times i have seen ads , but but now function is not working , can you help me please

Leave comment

Your email address will not be published. Required fields are marked with *.