error when adding the code to functions.php
-
Hello, I have added the code to my theme’s functions.php at the end, but it triggers 2 syntax errors which make the site not work when the functions.php file is updated and goes live.
Here is a screenshot that shows the code and errors.
https://www.northcoastcitizen.com/wp-content/uploads/2017/11/syntax_error.png
What needs to be done to fix this?
Thanks,
Erik
-
The <?php in line 1 of the functions.php file is never closed within the files code with a ?>
https://www.northcoastcitizen.com/wp-content/uploads/2017/11/top-1.pngIf I add ?> before adding the Invalid Click Protector code, then the syntax error goes away…what should I do? Should I add ?> in on line 1 or right before the ICP code?
There is no need to close the
?>php tag. Try replacing the single quote'and the double quotes"by actually typing the single and double quote. Sometimes when copying code, the quotes gives problem.Thanks, I followed your tips and got it working, just as you have detailed in the video.
But, I STILL am getting far far too many clicks, right away, just a few hours after enabling it. Not a single IP was banned during that time.
I have disabled my Ad Sense ads for now. What could cause this? A bot or something?
Hi,
Can you send me your site link with adsense enabled cause otherwise I can’t see if the plugin has properly implemented or not.Hello, I have the ads active on just this page for you to test:
https://www.northcoastcitizen.com/example/
The Ad Click limit is set for 2 and I have decided not to add any text to show after the click limit is reached.
I am using this shortcode widget plugin to bring in the shortcode: https://ww.wp.xz.cn/plugins/shortcode-widget/
This is the functions php code I am using:
add_shortcode( ‘googlead1’, function() {
if( aicp_can_see_ads() ) {
$adCode = ‘<div class=”aicp”>
<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!– Google ROS ATF Medrec –>
<ins class=”adsbygoogle”
style=”display:inline-block;width:300px;height:250px”
data-ad-client=”ca-pub-8954625665661382″
data-ad-slot=”4372104558″>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>’;
return $adCode;
} else {
return ‘<div class=”error”></div>’;
}
} );add_shortcode( ‘googlead2’, function() {
if( aicp_can_see_ads() ) {
$adCode = ‘<div class=”aicp”>
<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!– Responsive Ad –>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>’;
return $adCode;
} else {
return ‘<div class=”error”></div>’;
}
} );Hi,
I don’t see any adsense ads on your site though it is enabled. Check if you have added your adsense code properly or not.Hello, I have the Ad Sense Ads set to ONLY show up on this page right now, so you can test:
I’m accessing that page only but no adsense ads are showing up.
I am seeing them here, in the US, and have checked from connections on the west and east coasts of the country
There are 3 ads on the page, 1 at the top of the side rail, 1 at the middle of the side rail, and 1 below the “News” links…. Can you try refreshing your page a few times perhaps?
-
This reply was modified 8 years, 6 months ago by
countrymedia.
Yah I have seen it now and also tested. The plugin is working fine and hopefully my ip is in your blocked list too.
Hello, thank you for testing it out, I do see the IP address listed in the blocked list.
I enabled the same setup on the entire site last week, but got a bunch of invalid clicks on our ads right after turning them on, and no IP addresses were blocked.
Is it possible that a Bot or something was clicking the ads somehow, using different IP’s each time? What could be the cause?
And, should I try just enabling the ads on the articles only perhaps?
Well try enabling the as in your articles first. Also make sure your ads are not placed in places where people will accidentally click.
Hello, I enabled the ads on just articles only, but I started getting clicks again right away and no IP’s were blocked. Is it possible that a Bot or something was clicking the ads somehow, using different IP’s each time? What could be the cause?
I can try again and put the click limit to 1 instead of 2, but is there anything else I can do?
This is really odd what you are saying. You can try putting it to 1.
-
This reply was modified 8 years, 6 months ago by
The topic ‘error when adding the code to functions.php’ is closed to new replies.