¿Te preguntas cómo corregir el error de sintaxis en WordPress?
Hay muchos tutoriales de WordPress que te obligan a añadir fragmentos de código a tu sitio web. Desafortunadamente, un pequeño error puede hacer que todo el sitio se rompa, lo que da mucho miedo, especialmente para los nuevos usuarios. Si estabas probando algo nuevo en tu sitio WordPress y obtuviste el siguiente error “Error de sintaxis, inesperado…”, entonces no entres en pánico.
En este artículo, le mostraremos cómo corregir el error de sintaxis inesperado en WordPress.
Sintaxis correcta para evitar errores
Lo primero que tienes que hacer es consultar la guía para principiantes sobre cómo pegar fragmentos de código de la web en WordPress. Este artículo enumera algunos errores muy comunes cometidos por principiantes al pegar código en plantillas de WordPress.
El error de sintaxis suele deberse a un pequeño pero crucial error en la sintaxis de su código.
Por ejemplo, puede faltar una coma o sobrar una llave que puede romper todo el script.
¿Has pegado recientemente un fragmento de código de la web? ¿Ha actualizado un plugin? Entonces es probable que sepa exactamente dónde buscar.
Tutorial en vídeo
Si no te gusta el vídeo o necesitas más instrucciones, sigue leyendo.
Corrección del error de sintaxis mediante FTP
Para corregir el error de sintaxis, es necesario editar el código que causó este error. Puede eliminarlo o corregir la sintaxis.
A menudo los principiantes entran en pánico porque este error hace que todo su sitio se vuelva inaccesible. Si pegaste el código usando la sección Apariencia ” Editor de tu escritorio de WordPress, entonces estás bloqueado. Compruebe nuestra guía sobre qué hacer si está bloqueado en el administrador de WordPress.
¿Cómo se edita el código?
La única manera de corregir esto es acceder al archivo que editó por última vez utilizando FTP. Lee nuestra guía sobre cómo usar FTP para obtener instrucciones paso a paso.
Después de instalar el programa FTP, conéctalo a tu sitio web y ve al archivo del tema que necesitas editar. En caso de que olvide qué archivo necesita editar, simplemente mire el código de error. El error te dirá exactamente qué archivo y qué línea necesitas editar.
Puede eliminar el último código añadido o escribir el código en la sintaxis correcta. Una vez que haya eliminado o modificado el código, guarde el archivo y vuelva a subirlo a su servidor.
Después, visite su sitio WordPress, actualice la página y debería ver que su sitio vuelve a funcionar.
Cómo evitar el error de sintaxis en WordPress
Para evitar que su sitio web de WordPress se rompa de nuevo, siempre recomendamos añadir código personalizado con un plugin de fragmentos de código como WPCode.
WPCode facilita añadir fragmentos de código en WordPress sin tener que editar el archivo functions.php de tu tema.
Además, viene con validación inteligente de fragmentos de código para ayudarle a evitar los errores de código más comunes.
Mientras añades tu código personalizado, WPCode detectará automáticamente cualquier error. Al pasar el cursor sobre el error aparecerán instrucciones útiles para que puedas corregirlo fácilmente.
WPCode también desactivará inmediatamente tu código personalizado cuando detecte un error de sintaxis.
Ahora ya no tendrá que preocuparse de romper su sitio al añadir fragmentos de código.
Puede obtener más información en nuestra guía sobre cómo añadir fácilmente código personalizado en WordPress.
Esperamos que este artículo te haya ayudado a corregir el error de sintaxis en WordPress. También puedes consultar nuestra guía definitiva para aumentar la velocidad de WordPress y nuestra selección de los mejores editores de código para Mac y Windows.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and 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