Support Forum

AdSense Ad Not Appearing

26 Answers

New Answer

MP Mr Papa
Mr Papa
Member

sorry, the way you were talking, I thought you understood how standard WP filters work…

take the code I gave you in post #11 and put in your spFunctions.php file of your sp theme… as always, you should have a child theme or a custom theme before editing our themes…

you do not need to make any changes to our code files (ie the group header message)…

JE Justin Erickson
Justin Erickson
Member

I put the filter in the spFunctions.php. It will only work with the ad code in/with the filter.

I cant get the code to work in the Special group message section for the white background. 

When I had the filter in the group view functions the ad wouldn’t show while putting the code through the special group message. 

Now that it is in the functions, when trying the code through the special group message, it doesn’t work but shows “(adsbygoogle = window.adsbygoogle || []).push({});”?

Im not to sure what im doing wrong lol. 

MP Mr Papa
Mr Papa
Member

it will only work with the ad code in/with the filter

guess I dont know what you mean here as I dont think you are actually using a filter, so dont know what you are doing…

remember, I said you have to put your adsense code in the code fragment

$out.= ”;

so put your adsense code between the two single quotes.. of course, if you adsense code has single quotes you will need to escape or change to double quotes…

please paste your $out.= code fragment and we can help further…

JE Justin Erickson
Justin Erickson
Member

I thought the code in post #11 was the filter, “add_filter(‘sph_GroupHeaderMessage’, ‘my_header’);”?

Yes the adsense code is in the out.=;

With this the ad displays with no background. 

I can write a message in the special group message section and will display as normal with the background. The ad is then pushed down under the message section on its own.

Hope you understand what i’m saying.  

YS Yellow Swordfish
Yellow Swordfish
Member

So where are you with this this morning? I see an ad in what I assume you mean by the ‘white space’ so does that mean all is now well.

If not I have to say I don’t follow the above conversation enough to make much sense out of it. There seems much confusion so I will be asking you to start from scratch and tell me exactly what and where you want things

JE Justin Erickson
Justin Erickson
Member

I got the ad to show but no white background. It seems that the php code is adding another section under the original.

Ill start fresh.

In each group you have your: Group Name, Description, Select Custom Icon and Special group message to be displayed above forums.

I use the special group message to display my ads. When adding anything in this field it gives a white background so you can read the text. I will add text to the special group message for you to see what im talking about. It will say “Here”. You will see that it pushes the ad under the section. 

I want the ad to be in this field and not under it.

All im looking for is the adsense ad to work in the special group message.  

YS Yellow Swordfish
Yellow Swordfish
Member

Afraid I see no text saying ‘here’. As I said before – i DO see an Ad in the white space as in:

Screen-Shot-2017-01-23-at-17.21.42.png

which looks like the sort of thing you wanted…

JE Justin Erickson
Justin Erickson
Member

Hmmm that’s weird. Maybe I need to clear my cache. It caches the front page to everyone not logged in. 

I have 4 groups. The first one is what i’m working on. The other 3 already have ads from Amazon and Clickbank. They all work in the special message field. The adsense code will not work in the special message field. 

Here is a screenshot on what i’m talking about incase clearing the cache doesn’t work. And if it doesn’t work, then I have more problems then I thought. 

MKESCREENSHOT.png
YS Yellow Swordfish
Yellow Swordfish
Member

Well – when I reloaded the page I finally saw the ‘here’ but I don’t see that ad you just posted. The one I posted is the only one I see – correctly showing in the ‘white’ area.

JE Justin Erickson
Justin Erickson
Member

The ad you showed is just a picture with a link to a clickbank product.

The other 2 are amazon ad codes.

The one I showed is adsense. 

I just looked at it in mobile view on a different IP. The adsense ad doesn’t show at all. But the amazon ads do. I also have an adsense ad in the footer that did show. 

I cleared all cache and browser with the same result. 

So now I have 2 problems. I can’t get the adsense ad to show in the box. And why are coded ads not showing up for people in the special message box?

I have amazon coded ads all over with articles that display fine. 

I’m thinking there is something with the special message section that’s not allowing the code to display properly or at all. All my ad codes work outside the forums.  

JE Justin Erickson
Justin Erickson
Member

Here is the code I used in the functions.php to show the adsense ad in that screenshot. Maybe there is something missing?

I did just look at it on another IP and the amazon ads do show but not the adsense. Not to sure what I should do about this. Seems there is a bit of work on hand to get coded ads to work properly in the special message section. 

add_filter(‘sph_GroupHeaderMessage’, ‘my_header’);
function my_header($out) {
global $spThisGroup;
if ($spThisGroup->group_id == 2) {
# add adsense to $out here
$out.= ‘<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!– Milwaukee Auto Auctions –>
<ins class=”adsbygoogle”
style=”display:inline-block;width:728px;height:90px”
data-ad-client=”ca-pub-8679649126112925″
data-ad-slot=”1353012698″></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>’;
}
return $out;
}
?>

MP Mr Papa
Mr Papa
Member

So I too am seeing adsense ads on your forum group view… pretty much the code you showed here…  plus the ‘here’…  was that ad output another way?

this code definitely works – just tested it and your ad shows…

add_filter('sph_GroupHeaderMessage', 'my_header');
function my_header($out) {
    global $spThisGroup;
    if ($spThisGroup->group_id == 2) {
        # add adsense to $out here
        $out.= '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
            <!– Milwaukee Auto Auctions –>
            <ins class="adsbygoogle"
            style="display:inline-block;width:728px;height:90px"
            data-ad-client="ca-pub-8679649126112925"
            data-ad-slot="1353012698"></ins>
            <script>
            (adsbygoogle = window.adsbygoogle || []).push({});
            </script>';
    }
    return $out;
}

important.. your code (at least as pasted above) has some invalid quote characters…  please try copying the code above using the raw code button and then copying (dont just copy text from the forum display) to ensure you get proper quotes…