A simple question regarding adsense in action hooks

  • Ali


    I recently added an adsense banner on the graphene_after_post_content action hook. To my surprise, the homepage also displays the ads. I want the ads to appear only in the post’s page and not in the home page. How do I do this?


    Kenneth John Odle


    I did exactly the same thing and had the same issue. I wrote a tutorial for it, which you can rad read here:


    I mention a couple of different ways to handle it; you can choose what works for you.

    Good luck,




    Hi im having a problem using your procedure. It seems to work with other codes but for some reason when I use my adsense code it doesnt work. Why is that? is there any other way to do this? thanks



    Ken’s post should work for you. It’s the if statement that is determining whether or not to display on the homepage. The code within the statement should all be treated the same.

    Did you use a PHP widget? Did you use the IF statement?

    Can you post the code you used into http://www.pastebin.com and provide a link back here for us to look at?



    Hi! I did use the PHP widget. Here’s the code:




    Here’s the error I see when I use that code:

    Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /home/pcpinoyc/public_html/wp-content/plugins/wp-php-widget/wp-php-widget.php(52) : eval()’d code on line 6


    Kenneth John Odle


    You need to escape all the quotation marks in your echo statement. Just put a “” in front of them.



    Hi can you help me out? I have no idea how to do that. Is there some tutorial on that on the internet? it will be greatly appreciated thanks!



    Give this one a try:





    You could also begin the function with if (!is_front_page()) {YOUR CODE}

    This reads “If it is NOT front page, then execute the code. The exclamation point is used for NOT. This helps with not needing an ELSE code; and is just a little “cleaner”.

Viewing 10 posts - 1 through 10 (of 14 total)

  • 1
  • 2
  • You must be logged in to reply to this topic.
Do NOT follow this link or you will be banned from the site!