A simple question regarding adsense in action hooks

  • Ali

    #2296

    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?

    Mod

    Kenneth John Odle

    #19648

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

    http://blog.kjodle.net/2011/11/04/graphene-action-hook-widgets-an-easy-way-to-modify-your-blog/

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

    Good luck,

    Ken

    alrwebber

    #19649

    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

    Josh

    #19650

    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?

    alrwebber

    #19651

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

    http://pastebin.com/4dSU3cAw

    alrwebber

    #19652

    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

    Mod

    Kenneth John Odle

    #19653

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

    alrwebber

    #19654

    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!

    Josh

    #19655

    Give this one a try:

    http://pastebin.com/xMbQehVx

    Josh

    #19656

    FYI:

    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)

You must be logged in to reply to this topic.