Title: error when adding the code to functions.php
Last modified: November 9, 2017

---

# error when adding the code to functions.php

 *  Resolved [countrymedia](https://wordpress.org/support/users/countrymedia/)
 * (@countrymedia)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/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](https://www.northcoastcitizen.com/wp-content/uploads/2017/11/syntax_error.png)
 * What needs to be done to fix this?
 * Thanks,
    Erik

Viewing 14 replies - 1 through 14 (of 14 total)

 *  Thread Starter [countrymedia](https://wordpress.org/support/users/countrymedia/)
 * (@countrymedia)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9667763)
 * 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.png](https://www.northcoastcitizen.com/wp-content/uploads/2017/11/top-1.png)
 * If 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?
 *  Plugin Author [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9667807)
 * 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.
 *  Thread Starter [countrymedia](https://wordpress.org/support/users/countrymedia/)
 * (@countrymedia)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9668950)
 * 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?
 *  Plugin Author [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9669021)
 * 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.
 *  Thread Starter [countrymedia](https://wordpress.org/support/users/countrymedia/)
 * (@countrymedia)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9671363)
 * Hello, I have the ads active on just this page for you to test:
 * [https://www.northcoastcitizen.com/example/](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://wordpress.org/plugins/shortcode-widget/](https://wordpress.org/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>’; } } );
 *  Plugin Author [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9671454)
 * 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.
 *  Thread Starter [countrymedia](https://wordpress.org/support/users/countrymedia/)
 * (@countrymedia)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9671459)
 * Hello, I have the Ad Sense Ads set to ONLY show up on this page right now, so
   you can test:
 * [https://www.northcoastcitizen.com/example/](https://www.northcoastcitizen.com/example/)
 *  Plugin Author [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9671599)
 * I’m accessing that page only but no adsense ads are showing up.
 * > [View post on imgur.com](https://imgur.com/8yjG4j4)
 *  Thread Starter [countrymedia](https://wordpress.org/support/users/countrymedia/)
 * (@countrymedia)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9671678)
 * I am seeing them here, in the US, and have checked from connections on the west
   and east coasts of the country
 * [https://www.northcoastcitizen.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-10-at-12.42.33-PM.png](https://www.northcoastcitizen.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-10-at-12.42.33-PM.png)
 * 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](https://wordpress.org/support/users/countrymedia/).
 *  Plugin Author [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9672419)
 * Yah I have seen it now and also tested. The plugin is working fine and hopefully
   my ip is in your blocked list too.
 *  Thread Starter [countrymedia](https://wordpress.org/support/users/countrymedia/)
 * (@countrymedia)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9678590)
 * 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?
 *  Plugin Author [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9678889)
 * Well try enabling the as in your articles first. Also make sure your ads are 
   not placed in places where people will accidentally click.
 *  Thread Starter [countrymedia](https://wordpress.org/support/users/countrymedia/)
 * (@countrymedia)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9682622)
 * 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?
 *  Plugin Author [iSaumya](https://wordpress.org/support/users/isaumya/)
 * (@isaumya)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9682729)
 * This is really odd what you are saying. You can try putting it to 1.

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘error when adding the code to functions.php’ is closed to new replies.

 * ![](https://ps.w.org/ad-invalid-click-protector/assets/icon-256x256.png?rev=1534940)
 * [Ad Invalid Click Protector (AICP)](https://wordpress.org/plugins/ad-invalid-click-protector/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ad-invalid-click-protector/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ad-invalid-click-protector/)
 * [Active Topics](https://wordpress.org/support/plugin/ad-invalid-click-protector/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ad-invalid-click-protector/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ad-invalid-click-protector/reviews/)

 * 14 replies
 * 2 participants
 * Last reply from: [iSaumya](https://wordpress.org/support/users/isaumya/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/error-when-adding-the-code-to-functions-php/#post-9682729)
 * Status: resolved