I added Google AdSense code to the Forum PAGE.
http://www.goldminerrecipes.com/
The space where the ad should appear is showing, but it is blank. Can someone please tell me what I have done wrong? Thanks!
I added Google AdSense code to the Forum PAGE.
http://www.goldminerrecipes.com/
The space where the ad should appear is showing, but it is blank. Can someone please tell me what I have done wrong? Thanks!
I have to say that this is not my area of expertise and someone else probably need to chime in. But – all I see is some malformed or very old, invalid HTML.
Let’s start by asking you (a) is this the code that google supplied (and if so they should be ashamed!) and (b) where, exactly, did you put it? And how…?
Yes, this is code that Google supplied – straight from their AdSense page.
I went to the Dashboard >> Pages >> Forum and copied the code in the Text section of the window. The only thing that I added was the centering tags.
That existing code is Google ASYNCHRONOUS code. I am going to replace it with SYNCHRONOUS code and see what happens.
AHA! A good lesson for those who use AdSense in their forums. The SYNCHRONOUS code works, and the ASYNCHRONOUS code DOES NOT work! Thank you for all your help, Yellow Swordfish. If you hadn’t mentioned the Google code, I would never have found the problem.
I know its such an old topic but this is my exact problem.
SYNCHRONOUS and ASYNCHRONOUS codes dont work.
How would I add google adsense codes to these areas?
You can see here in the first group what the code looks like.
please see our faq: https://simple-press.com/documentation/codex/faq/how-to/faq-how-to-display-ads-in-the-forum/
I’m trying to add the ad in the “Special group message to be displayed above forums:” sections. Same as in the other groups with the amazon ads.
https://milwaukee-auto-market.com/
I’m trying to figure out how the code should be written. I’m in my cpanel file manager.
File:
sp-group-view-functions.php
Section:
sp_GroupHeaderMessage() # Display Special Group Message in Header # Scope: Group Loop # Version: 5.0 This is what I have.
if($spgroupview->currentgroup==2) {echo'ADSENSE CODE';}
I have it as group 2 as group 1 is disabled. Is this correct and where exactly would I put the code. I tried at the end of the section itself and it didn’t work.
Thanks
Justin
not sure what you are doing?? are you editing one of our functions? that would be a bad idea as you lose on upgrades… use our filters… so something like
add_filter('sph_GroupHeaderMessage', 'my_header');
function my_header($out) {
global $spThisGroup;
if ($spThisGroup->group_id == 2) {
# add adsense to $out here
$out.= '';
}
return $out;
}
should get you want you want… would put the adsense below the normal group header message… of course, you could just set $out equal to the adsense code if you want to replace it…
I tried and still can’t get it to work. I only know the basics for coding so try to bare with me.
I tried using the filter and shows no ad.
Here is the message section. Could you help me with implementing the code.
I just want to make sure I have the filter correct for group 2. If I do then I can move on with why its not working.
function sp_GroupHeaderMessage($args='') {
global $spThisGroup;
$defs = array('tagId' => 'spGroupHeaderMessage%ID%',
'tagClass' => 'spHeaderMessage',
'echo' => 1,
'get' => 0,
);
$a = wp_parse_args($args, $defs);
$a = apply_filters('sph_GroupHeaderMessage_args', $a);
extract($a, EXTR_SKIP);
# sanitize before use
$tagId = esc_attr($tagId);
$tagClass = esc_attr($tagClass);
$echo = (int) $echo;
$get = (int) $get;
$tagId = str_ireplace('%ID%', $spThisGroup->group_id, $tagId);
if ($get) return $spThisGroup->group_message;
$out = (empty($spThisGroup->group_message)) ? '' : "<div id='$tagId' class='$tagClass'>$spThisGroup->group_message</div>
";
$out = apply_filters('sph_GroupHeaderMessage', $out, $a);
if ($echo) {
echo $out;
} else {
return $out;
}
}
dont understand what that last code is? looks like our function, so not sure what it means…
I dont see you using a filter, so not sure what you mean by your filter??? do you just mean how you are checking for group id of 2??
If so, then no, yours is incorrect and its in mine:
if ($spThisGroup->group_id == 2)
where of course, $spThisGroup is a global…
I got the ad to show with the ad code in the filter – $out equal to.
Putting the code in the Simple:Press Administration group message section does not work for me.
I only have one small problem now. The white background is gone that came with the normal special message. This is how I get the icons to stand out.
You can see here in the first group the ad shows with no white background. In the second group is an ad through the Simple:Press Administration group message section.
How could I fix this?
The code I gave is the original code. I didn’t edit it at all. I was showing it to see if there is something in it preventing the ad to show.
I just put the filter you showed at the end.