Você está se perguntando como corrigir o erro de sintaxe no WordPress?
Há muitos tutoriais do WordPress que exigem que você adicione trechos de código ao seu site. Infelizmente, um pequeno erro pode fazer com que todo o site seja interrompido, o que é muito assustador, especialmente para novos usuários. Se você estava tentando algo novo em seu site do WordPress e recebeu o seguinte erro “Syntax error, unexpected…” (Erro de sintaxe, inesperado…), não entre em pânico.
Neste artigo, mostraremos a você como corrigir o erro de sintaxe inesperado no WordPress.
Usando a sintaxe correta para evitar erros
A primeira coisa que você precisa fazer é dar uma olhada no guia para iniciantes sobre como colar trechos da Web no WordPress. Esse artigo lista alguns erros muito comuns cometidos por iniciantes ao colar código em modelos do WordPress.
O erro de sintaxe geralmente é causado por um erro pequeno, mas crucial, na sintaxe do código.
Por exemplo, pode ser uma vírgula ausente ou uma chave extra que pode quebrar todo o script.
Você colou recentemente um snippet da Web? Atualizou um plug-in? Então é provável que você saiba exatamente onde procurar.
Tutorial em vídeo
Se você não gostar do vídeo ou precisar de mais instruções, continue lendo.
Como corrigir o erro de sintaxe usando FTP
Para corrigir o erro de sintaxe, você precisa editar o código que causou esse erro. Você pode removê-lo ou corrigir a sintaxe.
Muitas vezes, os iniciantes entram em pânico porque esse erro faz com que todo o seu site fique inacessível. Se você colou o código usando a seção Appearance ” Editor do painel do WordPress, então você está bloqueado. Confira nosso guia sobre o que fazer se você estiver bloqueado na administração do WordPress.
Então, como você edita o código?
A única maneira de corrigir isso é acessar o arquivo que foi editado pela última vez usando o FTP. Leia nosso guia sobre como usar o FTP para obter instruções passo a passo.
Depois de instalar o programa FTP, conecte-o ao seu site e acesse o arquivo do tema que precisa ser editado. Caso tenha esquecido qual arquivo precisa ser editado, basta observar o código de erro. O erro lhe dirá exatamente qual arquivo e qual linha você precisa editar.
Você pode remover o código que adicionou por último ou escrever o código na sintaxe correta. Quando terminar de remover ou editar o código, salve o arquivo e carregue-o de volta no servidor.
Depois disso, visite o site do WordPress, atualize a página e você verá que o site está funcionando novamente.
Como evitar o erro de sintaxe no WordPress
Para evitar que seu site do WordPress seja interrompido novamente, sempre recomendamos adicionar código personalizado com um plug-in de trechos de código como o WPCode.
O WPCode facilita a adição de trechos de código no WordPress sem a necessidade de editar o arquivo functions.php do seu tema.
Além disso, ele vem com validação inteligente de snippet de código para ajudá-lo a evitar erros comuns de código.
Ao adicionar seu código personalizado, o WPCode detectará automaticamente quaisquer erros. Ao passar o mouse sobre o erro, serão exibidas instruções úteis para que você possa corrigir o erro com facilidade.
O WPCode também desativará imediatamente seu código personalizado quando detectar um erro de sintaxe.
Agora, você não precisa mais se preocupar com a possibilidade de danificar seu site ao adicionar trechos de código.
Você pode saber mais em nosso guia sobre como adicionar facilmente códigos personalizados no WordPress.
Esperamos que este artigo tenha ajudado você a corrigir o erro de sintaxe no WordPress. Talvez você também queira ver nosso guia definitivo para aumentar a velocidade do WordPress e nossa seleção especializada dos melhores editores de código para Mac e Windows.
Se você gostou deste artigo, inscreva-se em nosso canal do YouTube para receber tutoriais em vídeo sobre o WordPress. Você também pode nos encontrar no Twitter e no Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Roberta says
This is a frustrating error and your tutorial allowed me to fix it in less than 5 minutes. Thank you so much!
Jamie den Haan says
Hi,
Can someone please help me out? I keep getting a ‘SyntaxError: JSON Parse error: Unexpected identifier ”Error” when i want to check out on my website. I don’t know what to do and nobody can place an order!!
Thanks a lot,
Jamie
Aaron says
I get “critical error: could not connect to server” when I enter my server information. So I can’t even get to the point that your video begins at.
WPBeginner Support says
Hi Aaron,
You can also connect to your server using File Manager app in your hosting account dashboard.
Administrador
Daryl says
You’re amazing. Thank you for these videos.
Raffy says
Thank you SO SO much! The bad snippet was invisible inside the Admin page in WordPress, for some reason, but fully visible in the functions.php found in the FTP!!
You saved my day, thank you very much again!
Kim martin says
Thank you SO much! 7 days of getting My hosting service(a very large popular one) to try to fix this no luck just trying to upsell me on things I neither want nor need.
Me thinking okay a whole new website and i found this, I just actually deleted the whole plugin(elementor) Whoo Hoo!
Micah says
Hello:
I have run into this error helping someone else out with their website, so I wasn’t using my actual website when I got this error. I’m wondering how I can remove the error when I’m working on someone else’s site? I have their wordpress. org login information, but obviously I’m locked out of everything now. Any guidance would be appreciated.
Tamia says
Thanks for this tutorial. I had a parsing/syntax problem when editing functions.php in a new website. I was working on the admin page of my WordPress site when I attempted to comment-out a line of code (using instructions by the theme author) but that caused the error. I had copied the functions.php code to TextWrangler, made the alteration, and pasted the whole doc back into the edit window. In “updating” the page I got the error and was effectively locked out of the site. So I used FTP to upload and overwrite the relevant doc, using a backup I’d made the previous day (thank goodness for those). If it hadn’t been for WP Beginner’s clear instructions here and on the “What To Do When You Are Locked Out of WordPress Admin (wp-admin)” post, I’d have been tearing my hair out. Thanks!
WPBeginner Support says
Hi Tamia,
We are glad you found WPBeginner article helpful Don’t forget to follow us on Facebook for more WordPress tips and tutorials.
Administrador
stanley says
Thanks for saving my website from errors
Tom Delano says
In trying to log into my page via Filezilla, am I supposed to use my admin account or my WordPress account? I’ve tried both and the password authentication keeps failing. I have my original admin password and it’s worked consistently since I’ve had the website up.
WPBeginner Support says
Hey Tom,
You’ll need to use your FTP username and password. You will find it in the email you received from your web hosting company when you first signed up. You can also find this information under your cPanel dashboard.
Administrador
chris says
thank you so much! you saved me
Justine says
I urgently need help. CO-editor on my site (which is supposed to launch tomorrow) tried to change code to change our profile pictures. Something went horribly wrong and we locked out of our site. Get this error: Parse error: syntax error, unexpected ‘add_filter’ (T_STRING) in
Giacomo Lawrance says
Thank you so much! You really saved me there. So grateful of this awesome site, thanks again!
Sara says
You saved my life!
Thank you so much!
Monica says
Re: my last comment, I deactivated the plugin and the error went away. So you won’t see what I was describing anymore. I just decided to not use it than try to spend all night figuring out the problem.
Monica says
I am getting parse error syntax errors on all my product pages. This was brought to my attention by someone trying to shop my site. I have not made any edits to the code, installed any new plugins, or accessed the site at all in months. Not sure when this started but I haven’t had an order in few weeks. If I didn’t add or edit anything to cause this how do I know what to fix? All the error messages reference line 1 of the php file but all there is on line 1 is <?php. It's on all product pages. Here is just one example:
shazwan says
Hi,
I’m managing a website for my society and its has been long since the last time everyone actually had logged into the hosting account and we kind of lost the log in credentials and didn’t even know what hosting we’re using because they paid years ahead before. And maybe changed providers. But I know that our domain is from Godaddy and checked, but the hosting isn’t from the same provider.
It may take some time as we dig through the emails, is there any way to fix syntax error other than through FTP?
WPBeginner Support says
Hi shazwan,
Unfortunately there is no way around it. There are online tools that will help you figure out where you website is hosted.
Administrador
Patrick says
Hi. I tried uploading a theme though Filezila since WordPress was having issues trying to upload the theme and now I’m locked up and I get these two lines
Please Help!!! Thank you!
WPBeginner Support says
Hi Patrick,
Seems like upload was interrupted. Please try uploading the theme files again.
Administrador