WordPress continues to prove itself as the most powerful CMS ever developed to date. With over 450 million websites on its network, the popular content management system powers over 35% of the internet today. This, perhaps, has to do with the fact that WordPress is super-flexible in terms of customization and API integration. And being a free CMS, it will probably remain at the top for a long long time.
As with any advanced system with a large community, errors are bound to happen. Many WordPress users will agree that you need some little PHP background to be able to use it effectively. This may not necessarily be true for customization – there are hundreds of cool page builders for that. But if you are trying to debug an issue on your WordPress website, you definitely need to play with some code.
One of the most common questions I get from my followers is how to remove the extra ” ?>); ” error on WordPress. The extra chunk of code normally appears at the top of the website and looks like some misplaced closing tags. In this guide, I’ll show you how to debug and fix this problem.
Temporarily Switch Themes
Ideally, this error should be tied to your theme via the header.php file. So the first smart move would be to check if this is the case. To do this, head over to your themes page and switch to another theme. I always recommend changing to one of the default WordPress themes. If the error disappears, you are good to go! Now let’s fix the issue on your theme.
Backup your header.php File
Now that we have confirmed that the problem is on your theme, it’s time to play with some theme files. Under “Appearance” on your WordPress dashboard, click on “Theme Editor”. This should list all your theme files with the style.css file opened by default.
Before you mess around with any theme files, it’s always a good idea to create a temporary backup in case something goes wrong. In our case, we are only interested in the header.php file. To edit this, select Theme Header (header.php) file from the theme files list on the right.
Highlight everything on the code editor window and copy. Then open a new notepad file (or any other word editor) and paste the copied code there. This will serve as our backup in case we need to restore anything.
Editing the header.php File
In the code editor window, hit Ctrl + F and search for the misplaced code (in this case ?>);). Alternatively, you can manually review the code to spot any misplaced syntax tags. If you have some background in PHP, this should be easy.
In my case, I found the tags just before the closing </head> tag. It is possible that the tags were copied and pasted by mistake while adding the Google Analytics tracking code as shown below.
Once you locate the erroneous code, delete it, update the file and Voila! Now, if you head back to your website, the error should be gone.
If you found this guide helpful, please leave a note in the comments section so we can talk more 🙂